From 14014ed88345a19b1e327acc9e7a9df7e490aabd Mon Sep 17 00:00:00 2001 From: Pascal Kuthe Date: Sun, 27 Aug 2023 17:22:21 +0200 Subject: [PATCH] reformat with rustfmt 1.71 --- matcher/src/fuzzy_greedy.rs | 2 +- matcher/src/fuzzy_optimal.rs | 8 ++------ matcher/src/matrix.rs | 2 +- src/lib.rs | 5 ++++- src/worker.rs | 10 ++++++++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/matcher/src/fuzzy_greedy.rs b/matcher/src/fuzzy_greedy.rs index 963818d..8215bf3 100644 --- a/matcher/src/fuzzy_greedy.rs +++ b/matcher/src/fuzzy_greedy.rs @@ -21,7 +21,7 @@ impl Matcher { if c.normalize(&self.config) == needle_char { let Some(next_needle_char) = needle_iter.next() else { // we found a match so we are now in the same state - // as the prefilter would produce + // as the prefilter would produce end = first_char_end + i + 1; break 'nonascii; }; diff --git a/matcher/src/fuzzy_optimal.rs b/matcher/src/fuzzy_optimal.rs index f007d79..10c7bcd 100644 --- a/matcher/src/fuzzy_optimal.rs +++ b/matcher/src/fuzzy_optimal.rs @@ -23,11 +23,7 @@ impl Matcher { // us to treat needle indices as u16 let Some(mut matrix) = self.slab.alloc(&haystack[start..end], needle.len()) else { return self.fuzzy_match_greedy_::( - haystack, - needle, - start, - greedy_end, - indices, + haystack, needle, start, greedy_end, indices, ); }; @@ -339,7 +335,7 @@ impl MatcherDataView<'_, H> { } let next_matched = row[col as usize].get(matched); if matched { - let Some((next_row_idx, next_row_off, next_row)) = row_iter.next() else{ + let Some((next_row_idx, next_row_off, next_row)) = row_iter.next() else { break; }; col += row_off - next_row_off; diff --git a/matcher/src/matrix.rs b/matcher/src/matrix.rs index d60e2a6..4af4535 100644 --- a/matcher/src/matrix.rs +++ b/matcher/src/matrix.rs @@ -148,7 +148,7 @@ impl MatrixSlab { let layout = Layout::new::(); // safety: the matrix is never zero sized (hardcoded constants) let ptr = unsafe { alloc_zeroed(layout) }; - let Some(ptr) = NonNull::new(ptr) else{ + let Some(ptr) = NonNull::new(ptr) else { handle_alloc_error(layout) }; MatrixSlab(ptr.cast()) diff --git a/src/lib.rs b/src/lib.rs index 59386bd..7331089 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -278,7 +278,10 @@ impl Nucleo { } else { let Some(worker) = self.worker.try_lock_arc_for(Duration::from_millis(timeout)) else { self.should_notify.store(true, Ordering::Release); - return Status{ changed: false, running: true }; + return Status { + changed: false, + running: true, + }; }; worker }; diff --git a/src/worker.rs b/src/worker.rs index 7b72257..e343be1 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -102,14 +102,20 @@ impl Worker { let Some(item) = item else { in_flight.lock().push(idx); unmatched.fetch_add(1, atomic::Ordering::Relaxed); - return Match { score: 0, idx: u32::MAX }; + return Match { + score: 0, + idx: u32::MAX, + }; }; if self.canceled.load(atomic::Ordering::Relaxed) { return Match { score: 0, idx }; } let Some(score) = pattern.score(item.matcher_columns, matchers.get()) else { unmatched.fetch_add(1, atomic::Ordering::Relaxed); - return Match { score: 0, idx: u32::MAX }; + return Match { + score: 0, + idx: u32::MAX, + }; }; Match { score, idx } });