Fix clippy errors

This commit is contained in:
ManyTheFish 2023-03-08 10:53:42 +01:00
parent 37d4551e8e
commit 3092cf0448
2 changed files with 7 additions and 7 deletions

View File

@ -100,6 +100,8 @@ pub async fn list_indexes(
Ok(Some(IndexView::new(uid.to_string(), index)?)) Ok(Some(IndexView::new(uid.to_string(), index)?))
})?; })?;
// Won't cause to open all indexes because IndexView doesn't keep the `Index` opened. // 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<IntoIter<Option<IndexView>>>`
#[allow(clippy::needless_collect)]
let indexes: Vec<IndexView> = indexes.into_iter().flatten().collect(); let indexes: Vec<IndexView> = indexes.into_iter().flatten().collect();
let ret = paginate.as_pagination().auto_paginate_sized(indexes.into_iter()); let ret = paginate.as_pagination().auto_paginate_sized(indexes.into_iter());

View File

@ -127,6 +127,7 @@ pub fn extract_docid_word_positions<R: io::Read + io::Seek>(
.map(|reader| (documents_ids, reader, script_language_docids)) .map(|reader| (documents_ids, reader, script_language_docids))
} }
#[allow(clippy::too_many_arguments)]
fn extract_tokens_from_document<T: AsRef<[u8]>>( fn extract_tokens_from_document<T: AsRef<[u8]>>(
obkv: &KvReader<FieldId>, obkv: &KvReader<FieldId>,
searchable_fields: &Option<HashSet<FieldId>>, searchable_fields: &Option<HashSet<FieldId>>,
@ -272,23 +273,20 @@ fn most_frequent_languages(
if languages_frequency.len() > 1 { if languages_frequency.len() > 1 {
let threshold = compute_laguage_frequency_threshold(languages_frequency); let threshold = compute_laguage_frequency_threshold(languages_frequency);
let languages: Vec<_> = languages_frequency let languages: Vec<_> =
.iter() languages_frequency.iter().filter(|(_, c)| *c > threshold).map(|(l, _)| *l).collect();
.filter(|(_, c)| *c > threshold)
.map(|(l, _)| l.clone())
.collect();
if languages.is_empty() { if languages.is_empty() {
None None
} else { } else {
Some((script.clone(), languages)) Some((*script, languages))
} }
} else { } else {
None 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(); let total: usize = languages_frequency.iter().map(|(_, c)| c).sum();
total / 20 // 5% is a completely arbitrar value. total / 20 // 5% is a completely arbitrar value.
} }