From f87a9503b7ca34d6c41d1e4f317d62f8aa32cc34 Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Tue, 10 Oct 2023 09:41:27 +0300 Subject: [PATCH 1/2] fix: clippy warnings Signed-off-by: Lachezar Lechev --- src/models/library_by_type.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/models/library_by_type.rs b/src/models/library_by_type.rs index a29a9430c..b1c15b9c3 100644 --- a/src/models/library_by_type.rs +++ b/src/models/library_by_type.rs @@ -147,7 +147,7 @@ fn catalogs_update( let r#type = catalog .first() .and_then(|first_page| first_page.first()) - .map(|library_item| &library_item.r#type) + .map(|library_item| library_item.r#type.as_str()) .expect("first page of library catalog is empty"); let size = catalog.iter().fold(0, |result, page| result + page.len()); result.insert(r#type, size); @@ -158,16 +158,16 @@ fn catalogs_update( .items .values() .filter(|library_item| F::predicate(library_item, notifications)) - .fold(HashMap::new(), |mut result, library_item| { + .fold(HashMap::<&str, Vec>::new(), |mut result, library_item| { result .entry(&library_item.r#type) - .or_insert_with(Vec::new) + .or_default() .push(library_item.to_owned()); result }) .into_iter() .sorted_by(|(a_type, _), (b_type, _)| { - compare_with_priorities(a_type.as_str(), b_type.as_str(), &*TYPE_PRIORITIES) + compare_with_priorities(*a_type, *b_type, &*TYPE_PRIORITIES) }) .rev() .map(|(r#type, library_items)| { From d6c718ca4594b01ec2bd133af9c1ec2fa6c9b48f Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Tue, 10 Oct 2023 09:46:11 +0300 Subject: [PATCH 2/2] fix: rustfmt Signed-off-by: Lachezar Lechev --- src/models/library_by_type.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/models/library_by_type.rs b/src/models/library_by_type.rs index b1c15b9c3..441a34e02 100644 --- a/src/models/library_by_type.rs +++ b/src/models/library_by_type.rs @@ -158,13 +158,16 @@ fn catalogs_update( .items .values() .filter(|library_item| F::predicate(library_item, notifications)) - .fold(HashMap::<&str, Vec>::new(), |mut result, library_item| { - result - .entry(&library_item.r#type) - .or_default() - .push(library_item.to_owned()); - result - }) + .fold( + HashMap::<&str, Vec>::new(), + |mut result, library_item| { + result + .entry(&library_item.r#type) + .or_default() + .push(library_item.to_owned()); + result + }, + ) .into_iter() .sorted_by(|(a_type, _), (b_type, _)| { compare_with_priorities(*a_type, *b_type, &*TYPE_PRIORITIES)