From 57a9c3c7e520714928904fc7e2ff3d62ac2b2467 Mon Sep 17 00:00:00 2001 From: Vika Date: Thu, 1 Aug 2024 17:20:52 +0300 Subject: 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. --- src/indieauth/mod.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') 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( .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); -- cgit 1.4.1