reformat with rustfmt 1.71

This commit is contained in:
Pascal Kuthe 2023-08-27 17:22:21 +02:00
parent b38fdfa8d7
commit 14014ed883
No known key found for this signature in database
GPG Key ID: D715E8655AE166A6
5 changed files with 16 additions and 11 deletions

View File

@ -23,11 +23,7 @@ impl Matcher {
// us to treat needle indices as u16 // us to treat needle indices as u16
let Some(mut matrix) = self.slab.alloc(&haystack[start..end], needle.len()) else { let Some(mut matrix) = self.slab.alloc(&haystack[start..end], needle.len()) else {
return self.fuzzy_match_greedy_::<INDICES, H, N>( return self.fuzzy_match_greedy_::<INDICES, H, N>(
haystack, haystack, needle, start, greedy_end, indices,
needle,
start,
greedy_end,
indices,
); );
}; };
@ -339,7 +335,7 @@ impl<H: Char> MatcherDataView<'_, H> {
} }
let next_matched = row[col as usize].get(matched); let next_matched = row[col as usize].get(matched);
if 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; break;
}; };
col += row_off - next_row_off; col += row_off - next_row_off;

View File

@ -148,7 +148,7 @@ impl MatrixSlab {
let layout = Layout::new::<MatcherData>(); let layout = Layout::new::<MatcherData>();
// safety: the matrix is never zero sized (hardcoded constants) // safety: the matrix is never zero sized (hardcoded constants)
let ptr = unsafe { alloc_zeroed(layout) }; let ptr = unsafe { alloc_zeroed(layout) };
let Some(ptr) = NonNull::new(ptr) else{ let Some(ptr) = NonNull::new(ptr) else {
handle_alloc_error(layout) handle_alloc_error(layout)
}; };
MatrixSlab(ptr.cast()) MatrixSlab(ptr.cast())

View File

@ -278,7 +278,10 @@ impl<T: Sync + Send + 'static> Nucleo<T> {
} else { } else {
let Some(worker) = self.worker.try_lock_arc_for(Duration::from_millis(timeout)) else { let Some(worker) = self.worker.try_lock_arc_for(Duration::from_millis(timeout)) else {
self.should_notify.store(true, Ordering::Release); self.should_notify.store(true, Ordering::Release);
return Status{ changed: false, running: true }; return Status {
changed: false,
running: true,
};
}; };
worker worker
}; };

View File

@ -102,14 +102,20 @@ impl<T: Sync + Send + 'static> Worker<T> {
let Some(item) = item else { let Some(item) = item else {
in_flight.lock().push(idx); in_flight.lock().push(idx);
unmatched.fetch_add(1, atomic::Ordering::Relaxed); 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) { if self.canceled.load(atomic::Ordering::Relaxed) {
return Match { score: 0, idx }; return Match { score: 0, idx };
} }
let Some(score) = pattern.score(item.matcher_columns, matchers.get()) else { let Some(score) = pattern.score(item.matcher_columns, matchers.get()) else {
unmatched.fetch_add(1, atomic::Ordering::Relaxed); unmatched.fetch_add(1, atomic::Ordering::Relaxed);
return Match { score: 0, idx: u32::MAX }; return Match {
score: 0,
idx: u32::MAX,
};
}; };
Match { score, idx } Match { score, idx }
}); });