From 9fffb8e83dd13cbe2d88655a258e5391b648d01e Mon Sep 17 00:00:00 2001 From: Tamo Date: Tue, 14 May 2024 17:20:57 +0200 Subject: [PATCH] make clippy happy --- index-scheduler/src/utils.rs | 4 ++-- meilisearch/src/search.rs | 2 +- milli/src/fieldids_weights_map.rs | 2 +- milli/src/index.rs | 8 ++++---- milli/src/search/new/bucket_sort.rs | 4 ++-- milli/src/search/new/mod.rs | 3 +-- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/index-scheduler/src/utils.rs b/index-scheduler/src/utils.rs index 9f6f90db2..260ff6ee4 100644 --- a/index-scheduler/src/utils.rs +++ b/index-scheduler/src/utils.rs @@ -272,9 +272,9 @@ pub fn swap_index_uid_in_task(task: &mut Task, swap: (&str, &str)) { } for index_uid in index_uids { if index_uid == swap.0 { - *index_uid = swap.1.to_owned(); + swap.1.clone_into(index_uid); } else if index_uid == swap.1 { - *index_uid = swap.0.to_owned(); + swap.0.clone_into(index_uid); } } } diff --git a/meilisearch/src/search.rs b/meilisearch/src/search.rs index a383434a2..34ebe463d 100644 --- a/meilisearch/src/search.rs +++ b/meilisearch/src/search.rs @@ -730,7 +730,7 @@ pub fn perform_search( let mut ids = BTreeSet::new(); for attr in attrs { if attr == "*" { - ids = displayed_ids.clone(); + ids.clone_from(&displayed_ids); break; } diff --git a/milli/src/fieldids_weights_map.rs b/milli/src/fieldids_weights_map.rs index bead160e9..fdfe8fba2 100644 --- a/milli/src/fieldids_weights_map.rs +++ b/milli/src/fieldids_weights_map.rs @@ -26,7 +26,7 @@ impl FieldidsWeightsMap { self.map.values().copied().max() } - pub fn ids<'a>(&'a self) -> impl Iterator + 'a { + pub fn ids(&self) -> impl Iterator + '_ { self.map.keys().copied() } } diff --git a/milli/src/index.rs b/milli/src/index.rs index 49f78f3cd..7fe9da0ff 100644 --- a/milli/src/index.rs +++ b/milli/src/index.rs @@ -632,7 +632,7 @@ impl Index { // Special case if there is no user defined fields. // Then the whole field id map is marked as searchable. if user_fields.is_none() { - let mut weights = self.fieldids_weights_map(&wtxn)?; + let mut weights = self.fieldids_weights_map(wtxn)?; let mut searchable = Vec::new(); for (weight, (fid, name)) in fields_ids_map.iter().enumerate() { searchable.push(name); @@ -648,7 +648,7 @@ impl Index { // We can write the user defined searchable fields as-is. self.put_user_defined_searchable_fields(wtxn, user_fields)?; - let mut weights = self.fieldids_weights_map(&wtxn)?; + let mut weights = self.fieldids_weights_map(wtxn)?; // Now we generate the real searchable fields: // 1. Take the user defined searchable fields as-is to keep the priority defined by the attributes criterion. @@ -666,7 +666,7 @@ impl Index { let weight: u16 = weight.try_into().map_err(|_| UserError::AttributeLimitReached)?; - weights.insert(id, weight as u16); + weights.insert(id, weight); } } } @@ -701,7 +701,7 @@ impl Index { self.main .remap_types::>>() .get(rtxn, main_key::SEARCHABLE_FIELDS_KEY)? - .map(|fields| Ok(fields.into_iter().map(|field| Cow::Borrowed(field)).collect())) + .map(|fields| Ok(fields.into_iter().map(Cow::Borrowed).collect())) .unwrap_or_else(|| { Ok(self .fields_ids_map(rtxn)? diff --git a/milli/src/search/new/bucket_sort.rs b/milli/src/search/new/bucket_sort.rs index 521fcb983..e9bc5449d 100644 --- a/milli/src/search/new/bucket_sort.rs +++ b/milli/src/search/new/bucket_sort.rs @@ -101,7 +101,7 @@ pub fn bucket_sort<'ctx, Q: RankingRuleQueryTrait>( let mut ranking_rule_universes: Vec = vec![RoaringBitmap::default(); ranking_rules_len]; - ranking_rule_universes[0] = universe.clone(); + ranking_rule_universes[0].clone_from(universe); let mut cur_ranking_rule_index = 0; /// Finish iterating over the current ranking rule, yielding @@ -232,7 +232,7 @@ pub fn bucket_sort<'ctx, Q: RankingRuleQueryTrait>( } cur_ranking_rule_index += 1; - ranking_rule_universes[cur_ranking_rule_index] = next_bucket.candidates.clone(); + ranking_rule_universes[cur_ranking_rule_index].clone_from(&next_bucket.candidates); logger.start_iteration_ranking_rule( cur_ranking_rule_index, ranking_rules[cur_ranking_rule_index].as_ref(), diff --git a/milli/src/search/new/mod.rs b/milli/src/search/new/mod.rs index 9a2ff5b02..b7514cbb5 100644 --- a/milli/src/search/new/mod.rs +++ b/milli/src/search/new/mod.rs @@ -178,8 +178,7 @@ pub struct SearchableFids { impl SearchableFids { pub fn contains(&self, fid: &FieldId) -> bool { - self.tolerant.iter().find(|(id, _)| id == fid).is_some() - || self.exact.iter().find(|(id, _)| id == fid).is_some() + self.tolerant.iter().any(|(id, _)| id == fid) || self.exact.iter().any(|(id, _)| id == fid) } }