about summary refs log tree commit diff
path: root/src/indieauth
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2024-08-01 17:20:52 +0300
committerVika <vika@fireburn.ru>2024-08-01 17:20:52 +0300
commit57a9c3c7e520714928904fc7e2ff3d62ac2b2467 (patch)
tree835afffdc3edcb1ea75c27055b42c57eb13a7b3a /src/indieauth
parent4bacba7cece901f9c25a450eb4b7bc8969bb5e9e (diff)
downloadkittybox-57a9c3c7e520714928904fc7e2ff3d62ac2b2467.tar.zst
indieauth: remove unnecessary cloning of MF2 items
Per clippy suggestion.

While they're behind a reference counter, and thus cloning is cheap,
we can avoid increasing the reference counter by borrowing here.

Also now the code is a bit prettier.
Diffstat (limited to 'src/indieauth')
-rw-r--r--src/indieauth/mod.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/indieauth/mod.rs b/src/indieauth/mod.rs
index 811bec6..26879bb 100644
--- a/src/indieauth/mod.rs
+++ b/src/indieauth/mod.rs
@@ -176,12 +176,18 @@ async fn authorization_endpoint_get<A: AuthBackend, D: Storage + 'static>(
                                 .into_response()
                         }
 
-                        mf2.items.iter()
+                        mf2.items
+                            .iter()
+                            .find(|&i| (**i).borrow().r#type.iter()
+                                .any(|i| {
+                                    *i == Class::from_str("h-app").unwrap()
+                                        || *i == Class::from_str("h-x-app").unwrap()
+                                })
+                            )
                             .cloned()
-                            .find(|i| (**i).borrow().r#type.iter()
-                                  .any(|i| *i == microformats::types::Class::from_str("h-app").unwrap()
-                                       || *i == microformats::types::Class::from_str("h-x-app").unwrap()))
-                            .map(|i| serde_json::to_value(i.borrow().deref()).unwrap())
+                            .map(|i| {
+                                serde_json::to_value(i.borrow().deref()).unwrap()
+                            })
                     },
                     Err(err) => {
                         tracing::error!("Error parsing application metadata: {}", err);