Skip to content

Commit cd400ad

Browse files
lint: resolve a few Clippy warnings
These changes only reflect a subset that I agreed with. PR #135
1 parent 56256dc commit cd400ad

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

Diff for: src/dfa.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ impl Builder {
494494
matches: vec![vec![]; num_match_states],
495495
matches_memory_usage: 0,
496496
pattern_lens: nnfa.pattern_lens_raw().to_vec(),
497-
prefilter: nnfa.prefilter().map(|p| p.clone()),
497+
prefilter: nnfa.prefilter().cloned(),
498498
match_kind: nnfa.match_kind(),
499499
state_len,
500500
alphabet_len: byte_classes.alphabet_len(),

Diff for: src/nfa/contiguous.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ impl<'a> State<'a> {
821821

822822
/// Return an iterator over every explicitly defined transition in this
823823
/// state.
824-
fn transitions<'b>(&'b self) -> impl Iterator<Item = (u8, StateID)> + 'b {
824+
fn transitions(&self) -> impl Iterator<Item = (u8, StateID)> + '_ {
825825
let mut i = 0;
826826
core::iter::from_fn(move || match self.trans {
827827
StateTrans::Sparse { classes, nexts } => {

Diff for: src/packed/api.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ impl<'s, 'h> Iterator for FindIter<'s, 'h> {
676676
if self.span.start > self.span.end {
677677
return None;
678678
}
679-
match self.searcher.find_in(&self.haystack, self.span) {
679+
match self.searcher.find_in(self.haystack, self.span) {
680680
None => None,
681681
Some(m) => {
682682
self.span.start = m.end();

Diff for: src/packed/pattern.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ pub(crate) struct Pattern<'a>(&'a [u8]);
211211
impl<'a> fmt::Debug for Pattern<'a> {
212212
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
213213
f.debug_struct("Pattern")
214-
.field("lit", &String::from_utf8_lossy(&self.0))
214+
.field("lit", &String::from_utf8_lossy(self.0))
215215
.finish()
216216
}
217217
}
@@ -224,7 +224,7 @@ impl<'p> Pattern<'p> {
224224

225225
/// Returns the bytes of this pattern.
226226
pub(crate) fn bytes(&self) -> &[u8] {
227-
&self.0
227+
self.0
228228
}
229229

230230
/// Returns the first `len` low nybbles from this pattern. If this pattern

Diff for: src/util/prefilter.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ struct Packed(packed::Searcher);
330330
impl PrefilterI for Packed {
331331
fn find_in(&self, haystack: &[u8], span: Span) -> Candidate {
332332
self.0
333-
.find_in(&haystack, span)
333+
.find_in(haystack, span)
334334
.map_or(Candidate::None, Candidate::Match)
335335
}
336336
}
@@ -549,7 +549,7 @@ impl RareBytesBuilder {
549549
let (mut bytes, mut len) = ([0; 3], 0);
550550
for b in 0..=255 {
551551
if builder.rare_set.contains(b) {
552-
bytes[len] = b as u8;
552+
bytes[len] = b;
553553
len += 1;
554554
}
555555
}
@@ -604,7 +604,7 @@ impl RareBytesBuilder {
604604
self.available = false;
605605
return;
606606
}
607-
let mut rarest = match bytes.get(0) {
607+
let mut rarest = match bytes.first() {
608608
None => return,
609609
Some(&b) => (b, freq_rank(b)),
610610
};
@@ -835,7 +835,7 @@ impl StartBytesBuilder {
835835
if self.count > 3 {
836836
return;
837837
}
838-
if let Some(&byte) = bytes.get(0) {
838+
if let Some(&byte) = bytes.first() {
839839
self.add_one_byte(byte);
840840
if self.ascii_case_insensitive {
841841
self.add_one_byte(opposite_ascii_case(byte));

0 commit comments

Comments
 (0)