From 7e3a164428a1046eec1888bd50ad6b647518db4b Mon Sep 17 00:00:00 2001 From: Hamir Mahal Date: Wed, 23 Oct 2024 10:10:07 -0700 Subject: [PATCH] style: simplify string formatting for readability --- src/tests.rs | 7 ++----- src/util/alphabet.rs | 6 +++--- src/util/error.rs | 12 ++++-------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/tests.rs b/src/tests.rs index a5276f8..ee77625 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1561,7 +1561,7 @@ fn regression_case_insensitive_prefilter() { for c2 in b'a'..b'z' { let c = c as char; let c2 = c2 as char; - let needle = format!("{}{}", c, c2).to_lowercase(); + let needle = format!("{c}{c2}").to_lowercase(); let haystack = needle.to_uppercase(); let ac = AhoCorasick::builder() .ascii_case_insensitive(true) @@ -1571,10 +1571,7 @@ fn regression_case_insensitive_prefilter() { assert_eq!( 1, ac.find_iter(&haystack).count(), - "failed to find {:?} in {:?}\n\nautomaton:\n{:?}", - needle, - haystack, - ac, + "failed to find {needle:?} in {haystack:?}\n\nautomaton:\n{ac:?}", ); } } diff --git a/src/util/alphabet.rs b/src/util/alphabet.rs index 69724fa..347d4f5 100644 --- a/src/util/alphabet.rs +++ b/src/util/alphabet.rs @@ -105,12 +105,12 @@ impl core::fmt::Debug for ByteClasses { if i > 0 { write!(f, ", ")?; } - write!(f, "{:?} => [", class)?; + write!(f, "{class:?} => [")?; for (start, end) in self.element_ranges(class) { if start == end { - write!(f, "{:?}", start)?; + write!(f, "{start:?}")?; } else { - write!(f, "{:?}-{:?}", start, end)?; + write!(f, "{start:?}-{end:?}")?; } } write!(f, "]")?; diff --git a/src/util/error.rs b/src/util/error.rs index 326d046..f7a0434 100644 --- a/src/util/error.rs +++ b/src/util/error.rs @@ -83,16 +83,14 @@ impl core::fmt::Display for BuildError { write!( f, "state identifier overflow: failed to create state ID \ - from {}, which exceeds the max of {}", - requested_max, max, + from {requested_max}, which exceeds the max of {max}", ) } ErrorKind::PatternIDOverflow { max, requested_max } => { write!( f, "pattern identifier overflow: failed to create pattern ID \ - from {}, which exceeds the max of {}", - requested_max, max, + from {requested_max}, which exceeds the max of {max}", ) } ErrorKind::PatternTooLong { pattern, len } => { @@ -236,15 +234,13 @@ impl core::fmt::Display for MatchError { MatchErrorKind::UnsupportedStream { got } => { write!( f, - "match kind {:?} does not support stream searching", - got, + "match kind {got:?} does not support stream searching", ) } MatchErrorKind::UnsupportedOverlapping { got } => { write!( f, - "match kind {:?} does not support overlapping searches", - got, + "match kind {got:?} does not support overlapping searches", ) } MatchErrorKind::UnsupportedEmpty => {