Skip to content

Commit

Permalink
Merge pull request #1297 from PSeitz/fix_clippy
Browse files Browse the repository at this point in the history
fix clippy issues
  • Loading branch information
PSeitz committed Mar 2, 2022
2 parents 458ed29 + 7fa6a0b commit 4b62f79
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 18 deletions.
10 changes: 4 additions & 6 deletions src/aggregation/bucket/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,15 @@ impl SegmentRangeCollector {
/// more computational expensive when many documents are hit.
fn to_u64_range(range: &RangeAggregationRange, field_type: &Type) -> crate::Result<Range<u64>> {
let start = if let Some(from) = range.from {
f64_to_fastfield_u64(from, field_type).ok_or::<TantivyError>(
TantivyError::InvalidArgument("invalid field type".to_string()),
)?
f64_to_fastfield_u64(from, field_type)
.ok_or_else(|| TantivyError::InvalidArgument("invalid field type".to_string()))?
} else {
u64::MIN
};

let end = if let Some(to) = range.to {
f64_to_fastfield_u64(to, field_type).ok_or::<TantivyError>(
TantivyError::InvalidArgument("invalid field type".to_string()),
)?
f64_to_fastfield_u64(to, field_type)
.ok_or_else(|| TantivyError::InvalidArgument("invalid field type".to_string()))?
} else {
u64::MAX
};
Expand Down
2 changes: 1 addition & 1 deletion src/aggregation/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl AggregationSegmentCollector {
agg: &Aggregations,
reader: &SegmentReader,
) -> crate::Result<Self> {
let aggs_with_accessor = get_aggs_with_accessor_and_validate(&agg, reader)?;
let aggs_with_accessor = get_aggs_with_accessor_and_validate(agg, reader)?;
let result =
SegmentAggregationResultsCollector::from_req_and_validate(&aggs_with_accessor)?;
Ok(AggregationSegmentCollector {
Expand Down
7 changes: 2 additions & 5 deletions src/aggregation/metric/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,8 @@ impl IntermediateStats {
}

pub(crate) fn standard_deviation(&self) -> Option<f64> {
if let Some(average) = self.avg() {
Some((self.square_mean() - average * average).sqrt())
} else {
None
}
self.avg()
.map(|average| (self.square_mean() - average * average).sqrt())
}

/// Merge data from other stats into this instance.
Expand Down
4 changes: 2 additions & 2 deletions src/aggregation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,8 +918,8 @@ mod tests {
let collector = AggregationCollector::from_aggs(agg_req_1);

let searcher = reader.searcher();
let agg_res = searcher.search(&AllQuery, &collector).unwrap_err();
agg_res

searcher.search(&AllQuery, &collector).unwrap_err()
};

let agg_res = avg_on_field("text");
Expand Down
4 changes: 2 additions & 2 deletions src/query/boolean_query/block_wand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn find_pivot_doc(
/// scorer in scorers[..pivot_len] and `scorer.doc()` for scorer in scorers[pivot_len..].
/// Note: before and after calling this method, scorers need to be sorted by their `.doc()`.
fn block_max_was_too_low_advance_one_scorer(
scorers: &mut Vec<TermScorerWithMaxScore>,
scorers: &mut [TermScorerWithMaxScore],
pivot_len: usize,
) {
debug_assert!(is_sorted(scorers.iter().map(|scorer| scorer.doc())));
Expand Down Expand Up @@ -82,7 +82,7 @@ fn block_max_was_too_low_advance_one_scorer(
// Given a list of term_scorers and a `ord` and assuming that `term_scorers[ord]` is sorted
// except term_scorers[ord] that might be in advance compared to its ranks,
// bubble up term_scorers[ord] in order to restore the ordering.
fn restore_ordering(term_scorers: &mut Vec<TermScorerWithMaxScore>, ord: usize) {
fn restore_ordering(term_scorers: &mut [TermScorerWithMaxScore], ord: usize) {
let doc = term_scorers[ord].doc();
for i in ord + 1..term_scorers.len() {
if term_scorers[i].doc() >= doc {
Expand Down
2 changes: 1 addition & 1 deletion src/tokenizer/ascii_folding_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@ fn fold_non_ascii_char(c: char) -> Option<&'static str> {
}

// https://github.com/apache/lucene-solr/blob/master/lucene/analysis/common/src/java/org/apache/lucene/analysis/miscellaneous/ASCIIFoldingFilter.java#L187
fn to_ascii(text: &mut String, output: &mut String) {
fn to_ascii(text: &str, output: &mut String) {
output.clear();

for c in text.chars() {
Expand Down
2 changes: 1 addition & 1 deletion src/tokenizer/lower_caser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct LowerCaserTokenStream<'a> {
}

// writes a lowercased version of text into output.
fn to_lowercase_unicode(text: &mut String, output: &mut String) {
fn to_lowercase_unicode(text: &str, output: &mut String) {
output.clear();
for c in text.chars() {
// Contrary to the std, we do not take care of sigma special case.
Expand Down

0 comments on commit 4b62f79

Please sign in to comment.