From 102fb506db100b59b7c3bc4d529db404d33b5d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 22 May 2019 11:00:58 +0200 Subject: [PATCH] chore: Do a little clippy pass --- meilidb-core/src/criterion/mod.rs | 1 - meilidb-core/src/distinct_map.rs | 4 ++-- meilidb-core/src/query_builder.rs | 10 +++------- meilidb-data/src/database/index.rs | 2 +- meilidb-data/src/indexer.rs | 6 +++--- meilidb-data/src/serde/convert_to_number.rs | 2 +- meilidb-data/src/serde/serializer.rs | 14 +++++--------- 7 files changed, 15 insertions(+), 24 deletions(-) diff --git a/meilidb-core/src/criterion/mod.rs b/meilidb-core/src/criterion/mod.rs index 2ed5a54ba..9b2962bdb 100644 --- a/meilidb-core/src/criterion/mod.rs +++ b/meilidb-core/src/criterion/mod.rs @@ -22,7 +22,6 @@ pub use self::{ pub trait Criterion: Send + Sync { fn evaluate(&self, lhs: &RawDocument, rhs: &RawDocument) -> Ordering; - #[inline] fn name(&self) -> &'static str; #[inline] diff --git a/meilidb-core/src/distinct_map.rs b/meilidb-core/src/distinct_map.rs index 81afe1cf0..3ac956245 100644 --- a/meilidb-core/src/distinct_map.rs +++ b/meilidb-core/src/distinct_map.rs @@ -12,7 +12,7 @@ impl DistinctMap { pub fn new(limit: usize) -> Self { DistinctMap { inner: HashMap::new(), - limit: limit, + limit, len: 0, } } @@ -31,7 +31,7 @@ pub struct BufferedDistinctMap<'a, K> { impl<'a, K: Hash + Eq> BufferedDistinctMap<'a, K> { pub fn new(internal: &'a mut DistinctMap) -> BufferedDistinctMap<'a, K> { BufferedDistinctMap { - internal: internal, + internal, inner: HashMap::new(), len: 0, } diff --git a/meilidb-core/src/query_builder.rs b/meilidb-core/src/query_builder.rs index b32fa3902..f9f51dba2 100644 --- a/meilidb-core/src/query_builder.rs +++ b/meilidb-core/src/query_builder.rs @@ -69,11 +69,7 @@ impl<'c, S, FI> QueryBuilder<'c, S, FI> where F: Fn(DocumentId) -> Option, K: Hash + Eq, { - DistinctQueryBuilder { - inner: self, - function: function, - size: size - } + DistinctQueryBuilder { inner: self, function, size } } pub fn add_searchable_attribute(&mut self, attribute: u16) { @@ -116,10 +112,10 @@ where S: Store, if self.searchable_attrs.as_ref().map_or(true, |r| r.contains(&di.attribute)) { let match_ = Match { query_index: iv.index as u32, - distance: distance, + distance, attribute: di.attribute, word_index: di.word_index, - is_exact: is_exact, + is_exact, char_index: di.char_index, char_length: di.char_length, }; diff --git a/meilidb-data/src/database/index.rs b/meilidb-data/src/database/index.rs index e75a02a9a..5db72e085 100644 --- a/meilidb-data/src/database/index.rs +++ b/meilidb-data/src/database/index.rs @@ -95,7 +95,7 @@ impl Index { let fields = fields .map(|fields| { fields - .into_iter() + .iter() .filter_map(|name| schema.attribute(name)) .collect() }); diff --git a/meilidb-data/src/indexer.rs b/meilidb-data/src/indexer.rs index 31d94ae4f..25c71d2de 100644 --- a/meilidb-data/src/indexer.rs +++ b/meilidb-data/src/indexer.rs @@ -134,9 +134,9 @@ fn token_to_docindex(id: DocumentId, attr: SchemaAttr, token: Token) -> Option Result { - Ok(Number::Float(OrderedFloat(value as f64))) + Ok(Number::Float(OrderedFloat(f64::from(value)))) } fn serialize_f64(self, value: f64) -> Result { diff --git a/meilidb-data/src/serde/serializer.rs b/meilidb-data/src/serde/serializer.rs index 0636d86d6..d201b3b4d 100644 --- a/meilidb-data/src/serde/serializer.rs +++ b/meilidb-data/src/serde/serializer.rs @@ -266,26 +266,22 @@ fn serialize_value( ) -> Result<(), SerializerError> where T: ser::Serialize, { - if let Some(attr) = schema.attribute(key) { - let props = schema.props(attr); + if let Some(attribute) = schema.attribute(key) { + let props = schema.props(attribute); if props.is_stored() { let value = rmp_serde::to_vec_named(value)?; - document_store.set_document_field(document_id, attr, value); + document_store.set_document_field(document_id, attribute, value); } if props.is_indexed() { - let indexer = Indexer { - attribute: attr, - indexer: indexer, - document_id: document_id, - }; + let indexer = Indexer { attribute, indexer, document_id }; value.serialize(indexer)?; } if props.is_ranked() { let number = value.serialize(ConvertToNumber)?; - ranked_map.insert(document_id, attr, number); + ranked_map.insert(document_id, attribute, number); } }