From 3092cf0448f2e7edeece7becc44d51c1adfe0a14 Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Wed, 8 Mar 2023 10:53:42 +0100 Subject: [PATCH] Fix clippy errors --- meilisearch/src/routes/indexes/mod.rs | 2 ++ .../extract/extract_docid_word_positions.rs | 12 +++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/meilisearch/src/routes/indexes/mod.rs b/meilisearch/src/routes/indexes/mod.rs index c5c168786..487511da0 100644 --- a/meilisearch/src/routes/indexes/mod.rs +++ b/meilisearch/src/routes/indexes/mod.rs @@ -100,6 +100,8 @@ pub async fn list_indexes( Ok(Some(IndexView::new(uid.to_string(), index)?)) })?; // Won't cause to open all indexes because IndexView doesn't keep the `Index` opened. + // error when trying to fix it: the trait `ExactSizeIterator` is not implemented for `Flatten>>` + #[allow(clippy::needless_collect)] let indexes: Vec = indexes.into_iter().flatten().collect(); let ret = paginate.as_pagination().auto_paginate_sized(indexes.into_iter()); diff --git a/milli/src/update/index_documents/extract/extract_docid_word_positions.rs b/milli/src/update/index_documents/extract/extract_docid_word_positions.rs index 5a103f1e0..057559462 100644 --- a/milli/src/update/index_documents/extract/extract_docid_word_positions.rs +++ b/milli/src/update/index_documents/extract/extract_docid_word_positions.rs @@ -127,6 +127,7 @@ pub fn extract_docid_word_positions( .map(|reader| (documents_ids, reader, script_language_docids)) } +#[allow(clippy::too_many_arguments)] fn extract_tokens_from_document>( obkv: &KvReader, searchable_fields: &Option>, @@ -272,23 +273,20 @@ fn most_frequent_languages( if languages_frequency.len() > 1 { let threshold = compute_laguage_frequency_threshold(languages_frequency); - let languages: Vec<_> = languages_frequency - .iter() - .filter(|(_, c)| *c > threshold) - .map(|(l, _)| l.clone()) - .collect(); + let languages: Vec<_> = + languages_frequency.iter().filter(|(_, c)| *c > threshold).map(|(l, _)| *l).collect(); if languages.is_empty() { None } else { - Some((script.clone(), languages)) + Some((*script, languages)) } } else { None } } -fn compute_laguage_frequency_threshold(languages_frequency: &Vec<(Language, usize)>) -> usize { +fn compute_laguage_frequency_threshold(languages_frequency: &[(Language, usize)]) -> usize { let total: usize = languages_frequency.iter().map(|(_, c)| c).sum(); total / 20 // 5% is a completely arbitrar value. }