Skip to content

Commit

Permalink
Applied clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
leontoeides committed Mar 29, 2024
1 parent 03c4d41 commit 6fd19bf
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/simple/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl<K: Clone + Ord> SearchIndexBuilder<K> {
///
/// [`StrsimMetric`]: enum.StrsimMetric.html
#[cfg(feature = "strsim")]
pub const fn strsim_metric(mut self, strsim_metric: Option<StrsimMetric>) -> Self {
#[must_use] pub const fn strsim_metric(mut self, strsim_metric: Option<StrsimMetric>) -> Self {
self.strsim_metric = strsim_metric;
self
} // fn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl<K: Hash + Ord> SearchIndex<K> {
// Insert the score into the top scores (if it's normal and high
// enough):
if score.is_normal() && score >= self.fuzzy_minimum_score {
top_scores.insert(index_keyword, index_keys, score)
top_scores.insert(index_keyword, index_keys, score);
} // if
}); // for_each

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl<K: Hash + Ord> SearchIndex<K> {
// Insert the score into the top scores (if it's normal and high
// enough):
if score.is_normal() && score >= self.fuzzy_minimum_score {
top_scores.insert(index_keyword, index_keys, score)
top_scores.insert(index_keyword, index_keys, score);
} // if
}); // for_each

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl<K: Hash + Ord> SearchIndex<K> {
// Insert the score into the top scores (if it's normal and high
// enough):
if score.is_normal() && score >= self.fuzzy_minimum_score {
top_scores.insert(index_keyword, index_keys, score)
top_scores.insert(index_keyword, index_keys, score);
} // if
}); // for_each

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<K: Hash + Ord> SearchIndex<K> {
// Insert the score into the top scores (if it's normal and high
// enough):
if score.is_normal() && score >= self.fuzzy_minimum_score {
top_scores.insert(index_keyword, index_keys, score)
top_scores.insert(index_keyword, index_keys, score);
} // if
}); // for_each

Expand Down
20 changes: 10 additions & 10 deletions src/simple/internal/strsim/autocomplete/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! Fuzzy matching for autocompletion.
pub(crate) mod context_damerau_levenshtein;
pub(crate) mod context_jaro;
pub(crate) mod context_jaro_winkler;
pub(crate) mod context_levenshtein;
pub(crate) mod context_sorensen_dice;
pub(crate) mod global_damerau_levenshtein;
pub(crate) mod global_jaro;
pub(crate) mod global_jaro_winkler;
pub(crate) mod global_levenshtein;
pub(crate) mod global_sorensen_dice;
pub mod context_damerau_levenshtein;
pub mod context_jaro;
pub mod context_jaro_winkler;
pub mod context_levenshtein;
pub mod context_sorensen_dice;
pub mod global_damerau_levenshtein;
pub mod global_jaro;
pub mod global_jaro_winkler;
pub mod global_levenshtein;
pub mod global_sorensen_dice;
10 changes: 5 additions & 5 deletions src/simple/internal/strsim/keyword/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Fuzzy matching for keyword substitution.
pub(crate) mod global_damerau_levenshtein;
pub(crate) mod global_jaro;
pub(crate) mod global_jaro_winkler;
pub(crate) mod global_levenshtein;
pub(crate) mod global_sorensen_dice;
pub mod global_damerau_levenshtein;
pub mod global_jaro;
pub mod global_jaro_winkler;
pub mod global_levenshtein;
pub mod global_sorensen_dice;
11 changes: 6 additions & 5 deletions src/simple/internal/strsim/strsim_autocomplete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@ impl<K: Hash + Ord> SearchIndex<K> {
/// );
/// ```
pub fn strsim_autocomplete(&self, keyword: &str) -> Vec<&str> {
#[must_use] pub fn strsim_autocomplete(&self, keyword: &str) -> Vec<&str> {
// If case sensitivity set, leave case intact. Otherwise, normalize
// keyword to lower case:
let keyword = match self.case_sensitive {
true => keyword.to_string(),
false => keyword.to_lowercase(),
}; // match
let keyword = if self.case_sensitive {
keyword.to_string()
} else {
keyword.to_lowercase()
};

// Call global autocompletion provider:
self.strsim_global_autocomplete(&keyword)
Expand Down
1 change: 1 addition & 0 deletions src/simple/internal/strsim/strsim_context_autocomplete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl<K: Hash + Ord> SearchIndex<K> {
// Attempt to find the top matches for the user's (partial) keyword
// using the selected string similarity metric defined in the
// `SearchIndex`:
#[allow(clippy::option_if_let_else)] // This lint makes things less readable 👎
if let Some(strsim_metric) = &self.strsim_metric {
match strsim_metric {
StrsimMetric::DamerauLevenshtein => self
Expand Down
1 change: 1 addition & 0 deletions src/simple/internal/strsim/strsim_global_autocomplete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ impl<K: Hash + Ord> SearchIndex<K> {
// Attempt to find the top matches for the user's (partial) keyword
// using the selected string similarity metric defined in the
// `SearchIndex`:
#[allow(clippy::option_if_let_else)] // I don't like this lint
if let Some(strsim_metric) = &self.strsim_metric {
match strsim_metric {
StrsimMetric::DamerauLevenshtein => self
Expand Down
1 change: 1 addition & 0 deletions src/simple/internal/strsim/strsim_global_keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl<K: Hash + Ord> SearchIndex<K> {

// Attempt to find the closest match for the user's keyword using the
// selected string similarity metric defined in the `SearchIndex`:
#[allow(clippy::option_if_let_else)] // I hate this lint
if let Some(strsim_metric) = &self.strsim_metric {
match strsim_metric {
StrsimMetric::DamerauLevenshtein => {
Expand Down
13 changes: 7 additions & 6 deletions src/simple/internal/strsim/strsim_keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,17 @@ impl<K: Hash + Ord> SearchIndex<K> {
/// );
/// ```
pub fn strsim_keyword(&self, keyword: &str) -> Option<&str> {
#[must_use] pub fn strsim_keyword(&self, keyword: &str) -> Option<&str> {
// If case sensitivity set, leave case intact. Otherwise, normalize
// keyword to lower case:
let keyword = match self.case_sensitive {
true => keyword.to_string(),
false => keyword.to_lowercase(),
}; // match
let keyword = if self.case_sensitive {
keyword.to_string()
} else {
keyword.to_lowercase()
}; // if

// Call global keyword subtitution provider:
self.strsim_global_keyword(&keyword)
.map(|kstring| kstring.as_str())
.map(kstring::KStringBase::as_str)
} // fn
} // impl
4 changes: 2 additions & 2 deletions src/simple/search/live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl<K: Hash + Ord> SearchIndex<K> {
.take(*maximum_search_results)
// Collect all keyword autocompletions into a
// `BTreeSet`:
.collect()
.collect();
} // if

// Return search results to caller:
Expand Down Expand Up @@ -296,7 +296,7 @@ impl<K: Hash + Ord> SearchIndex<K> {
.take(*maximum_search_results)
// Collect all keyword autocompletions into a
// `BTreeSet`:
.collect()
.collect();
} // if

// Return search results to caller:
Expand Down

0 comments on commit 6fd19bf

Please sign in to comment.