Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: simplify string formatting for readability #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:?}",
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/util/alphabet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, "]")?;
Expand Down
12 changes: 4 additions & 8 deletions src/util/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 } => {
Expand Down Expand Up @@ -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 => {
Expand Down
Loading