edition: run 'cargo fix --edition --edition-idioms'

This commit is contained in:
Andrew Gallant
2021-04-30 18:38:36 -04:00
parent e506f5c9b2
commit 09e34c19d4
11 changed files with 22 additions and 30 deletions
-6
View File
@@ -28,12 +28,6 @@ Add this to your `Cargo.toml`:
aho-corasick = "0.7"
```
and this to your crate root (if you're using Rust 2015):
```rust
extern crate aho_corasick;
```
### Example: basic searching
+2 -3
View File
@@ -1,4 +1,3 @@
extern crate aho_corasick;
#[macro_use]
extern crate criterion;
@@ -159,7 +158,7 @@ fn define(
group_name: &str,
bench_name: &str,
corpus: &[u8],
bench: impl FnMut(&mut Bencher) + 'static,
bench: impl FnMut(&mut Bencher<'_>) + 'static,
) {
let tput = Throughput::Bytes(corpus.len() as u64);
let benchmark = Benchmark::new(bench_name, bench)
@@ -177,7 +176,7 @@ fn define_long(
group_name: &str,
bench_name: &str,
corpus: &[u8],
bench: impl FnMut(&mut Bencher) + 'static,
bench: impl FnMut(&mut Bencher<'_>) + 'static,
) {
let tput = Throughput::Bytes(corpus.len() as u64);
let benchmark = Benchmark::new(bench_name, bench)
+4 -4
View File
@@ -1169,7 +1169,7 @@ impl<S: StateID> Imp<S> {
///
/// The lifetime `'b` refers to the lifetime of the haystack being searched.
#[derive(Debug)]
pub struct FindIter<'a, 'b, S: 'a + StateID> {
pub struct FindIter<'a, 'b, S: StateID> {
fsm: &'a Imp<S>,
prestate: PrefilterState,
haystack: &'b [u8],
@@ -1226,7 +1226,7 @@ impl<'a, 'b, S: StateID> Iterator for FindIter<'a, 'b, S> {
///
/// The lifetime `'b` refers to the lifetime of the haystack being searched.
#[derive(Debug)]
pub struct FindOverlappingIter<'a, 'b, S: 'a + StateID> {
pub struct FindOverlappingIter<'a, 'b, S: StateID> {
fsm: &'a Imp<S>,
prestate: PrefilterState,
haystack: &'b [u8],
@@ -1297,7 +1297,7 @@ impl<'a, 'b, S: StateID> Iterator for FindOverlappingIter<'a, 'b, S> {
///
/// The lifetime `'a` refers to the lifetime of the `AhoCorasick` automaton.
#[derive(Debug)]
pub struct StreamFindIter<'a, R, S: 'a + StateID> {
pub struct StreamFindIter<'a, R, S: StateID> {
it: StreamChunkIter<'a, R, S>,
}
@@ -1332,7 +1332,7 @@ impl<'a, R: io::Read, S: StateID> Iterator for StreamFindIter<'a, R, S> {
/// N.B. This does not actually implement Iterator because we need to borrow
/// from the underlying reader. But conceptually, it's still an iterator.
#[derive(Debug)]
struct StreamChunkIter<'a, R, S: 'a + StateID> {
struct StreamChunkIter<'a, R, S: StateID> {
/// The AC automaton.
fsm: &'a Imp<S>,
/// State associated with this automaton's prefilter. It is a heuristic
+2 -2
View File
@@ -64,7 +64,7 @@ impl ByteClasses {
/// hasn't been converted to equivalence classes yet. Picking an arbitrary
/// byte from each equivalence class then permits a full exploration of
/// the NFA instead of using every possible byte value.
pub fn representatives(&self) -> ByteClassRepresentatives {
pub fn representatives(&self) -> ByteClassRepresentatives<'_> {
ByteClassRepresentatives { classes: self, byte: 0, last_class: None }
}
@@ -85,7 +85,7 @@ impl ByteClasses {
}
impl fmt::Debug for ByteClasses {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_singleton() {
write!(f, "ByteClasses({{singletons}})")
} else {
+1 -1
View File
@@ -68,7 +68,7 @@ impl error::Error for Error {
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.kind {
ErrorKind::StateIDOverflow { max } => write!(
f,
-1
View File
@@ -186,7 +186,6 @@ disabled via
#[cfg(not(feature = "std"))]
compile_error!("`std` feature is currently required to build this crate");
extern crate memchr;
// #[cfg(doctest)]
// #[macro_use]
// extern crate doc_comment;
+3 -3
View File
@@ -172,7 +172,7 @@ impl<S: StateID> NFA<S> {
self.state_mut(id)
}
fn iter_transitions_mut(&mut self, id: S) -> IterTransitionsMut<S> {
fn iter_transitions_mut(&mut self, id: S) -> IterTransitionsMut<'_, S> {
IterTransitionsMut::new(self, id)
}
@@ -497,7 +497,7 @@ impl<S: StateID> Transitions<S> {
/// is iterating over transitions, the caller can still mutate the NFA. This
/// is useful when creating failure transitions.
#[derive(Debug)]
struct IterTransitionsMut<'a, S: StateID + 'a> {
struct IterTransitionsMut<'a, S: StateID> {
nfa: &'a mut NFA<S>,
state_id: S,
cur: usize,
@@ -1274,7 +1274,7 @@ impl Iterator for AllBytesIter {
}
impl<S: StateID> fmt::Debug for NFA<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "NFA(")?;
writeln!(f, "match_kind: {:?}", self.match_kind)?;
writeln!(f, "prefilter: {:?}", self.prefilter)?;
+4 -4
View File
@@ -155,7 +155,7 @@ impl Patterns {
/// Return the pattern with the given identifier. If such a pattern does
/// not exist, then this panics.
pub fn get(&self, id: PatternID) -> Pattern {
pub fn get(&self, id: PatternID) -> Pattern<'_> {
Pattern(&self.by_id[id as usize])
}
@@ -167,7 +167,7 @@ impl Patterns {
/// Callers must ensure that a pattern with the given identifier exists
/// before using this method.
#[cfg(target_arch = "x86_64")]
pub unsafe fn get_unchecked(&self, id: PatternID) -> Pattern {
pub unsafe fn get_unchecked(&self, id: PatternID) -> Pattern<'_> {
Pattern(self.by_id.get_unchecked(id as usize))
}
@@ -189,7 +189,7 @@ impl Patterns {
/// the order provided by this iterator, then the result is guaranteed
/// to satisfy the correct match semantics. (Either leftmost-first or
/// leftmost-longest.)
pub fn iter(&self) -> PatternIter {
pub fn iter(&self) -> PatternIter<'_> {
PatternIter { patterns: self, i: 0 }
}
}
@@ -226,7 +226,7 @@ impl<'p> Iterator for PatternIter<'p> {
pub struct Pattern<'a>(&'a [u8]);
impl<'a> fmt::Debug for Pattern<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Pattern")
.field("lit", &String::from_utf8_lossy(&self.0))
.finish()
+2 -2
View File
@@ -296,7 +296,7 @@ impl<'p> Compiler<'p> {
}
impl<'p> fmt::Debug for Compiler<'p> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut buckets = vec![vec![]; self.buckets.len()];
for (i, bucket) in self.buckets.iter().enumerate() {
for &patid in bucket {
@@ -400,7 +400,7 @@ impl Mask {
}
impl fmt::Debug for Mask {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let (mut parts_lo, mut parts_hi) = (vec![], vec![]);
for i in 0..32 {
parts_lo.push(format!("{:02}: {:08b}", i, self.lo[i]));
+2 -2
View File
@@ -1,11 +1,11 @@
#[cfg(target_arch = "x86_64")]
pub use crate::packed::teddy::compile::Builder;
#[cfg(target_arch = "x86_64")]
pub use crate::packed::teddy::runtime::Teddy;
#[cfg(not(target_arch = "x86_64"))]
pub use packed::teddy::fallback::Builder;
#[cfg(not(target_arch = "x86_64"))]
pub use packed::teddy::fallback::Teddy;
#[cfg(target_arch = "x86_64")]
pub use crate::packed::teddy::runtime::Teddy;
#[cfg(target_arch = "x86_64")]
mod compile;
+2 -2
View File
@@ -435,7 +435,7 @@ impl ByteSet {
}
impl fmt::Debug for ByteSet {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut bytes = vec![];
for b in 0..=255 {
if self.contains(b) {
@@ -471,7 +471,7 @@ impl RareByteOffsets {
}
impl fmt::Debug for RareByteOffsets {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut offsets = vec![];
for off in self.set.iter() {
if off.max > 0 {