diff --git a/src/error.rs b/src/error.rs index 6026b3849..0f222c537 100644 --- a/src/error.rs +++ b/src/error.rs @@ -71,8 +71,7 @@ impl core::fmt::Display for Error { Error::Syntax(ref err) => err.fmt(f), Error::CompiledTooBig(limit) => write!( f, - "Compiled regex exceeds size limit of {} bytes.", - limit + "Compiled regex exceeds size limit of {limit} bytes." ), } } @@ -88,9 +87,9 @@ impl core::fmt::Debug for Error { Error::Syntax(ref err) => { let hr: String = core::iter::repeat('~').take(79).collect(); writeln!(f, "Syntax(")?; - writeln!(f, "{}", hr)?; - writeln!(f, "{}", err)?; - writeln!(f, "{}", hr)?; + writeln!(f, "{hr}")?; + writeln!(f, "{err}")?; + writeln!(f, "{hr}")?; write!(f, ")")?; Ok(()) } diff --git a/src/regex/bytes.rs b/src/regex/bytes.rs index 39af6e71c..c5b40c370 100644 --- a/src/regex/bytes.rs +++ b/src/regex/bytes.rs @@ -1787,7 +1787,7 @@ impl<'h> Captures<'h> { .expect("number of capture groups can vary in a match") .checked_sub(1) .expect("number of groups is always greater than zero"); - assert_eq!(N, len, "asked for {} groups, but must ask for {}", N, len); + assert_eq!(N, len, "asked for {N} groups, but must ask for {len}"); // The regex-automata variant of extract is a bit more permissive. // It doesn't require the number of matching capturing groups to be // static, and you can even request fewer groups than what's there. So @@ -1942,7 +1942,7 @@ impl<'h> core::fmt::Debug for Captures<'h> { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "{}", self.0)?; if let Some(name) = self.1 { - write!(f, "/{:?}", name)?; + write!(f, "/{name:?}")?; } Ok(()) } @@ -2646,7 +2646,7 @@ mod tests { fn test_debug_output_valid_utf8() { let haystack = b"Hello, world!"; let m = Match::new(haystack, 7, 12); - let debug_str = format!("{:?}", m); + let debug_str = format!("{m:?}"); assert_eq!( debug_str, @@ -2658,7 +2658,7 @@ mod tests { fn test_debug_output_invalid_utf8() { let haystack = b"Hello, \xFFworld!"; let m = Match::new(haystack, 7, 13); - let debug_str = format!("{:?}", m); + let debug_str = format!("{m:?}"); assert_eq!( debug_str, @@ -2671,7 +2671,7 @@ mod tests { let haystack = "Hello, 😊 world! 안녕하세요? مرحبا بالعالم!".as_bytes(); let m = Match::new(haystack, 0, haystack.len()); - let debug_str = format!("{:?}", m); + let debug_str = format!("{m:?}"); assert_eq!( debug_str, @@ -2683,7 +2683,7 @@ mod tests { fn test_debug_output_ascii_escape() { let haystack = b"Hello,\tworld!\nThis is a \x1b[31mtest\x1b[0m."; let m = Match::new(haystack, 0, haystack.len()); - let debug_str = format!("{:?}", m); + let debug_str = format!("{m:?}"); assert_eq!( debug_str, @@ -2695,7 +2695,7 @@ mod tests { fn test_debug_output_match_in_middle() { let haystack = b"The quick brown fox jumps over the lazy dog."; let m = Match::new(haystack, 16, 19); - let debug_str = format!("{:?}", m); + let debug_str = format!("{m:?}"); assert_eq!(debug_str, r#"Match { start: 16, end: 19, bytes: "fox" }"#); } diff --git a/src/regex/string.rs b/src/regex/string.rs index fab178a68..266595d2a 100644 --- a/src/regex/string.rs +++ b/src/regex/string.rs @@ -1797,7 +1797,7 @@ impl<'h> Captures<'h> { .expect("number of capture groups can vary in a match") .checked_sub(1) .expect("number of groups is always greater than zero"); - assert_eq!(N, len, "asked for {} groups, but must ask for {}", N, len); + assert_eq!(N, len, "asked for {N} groups, but must ask for {len}"); // The regex-automata variant of extract is a bit more permissive. // It doesn't require the number of matching capturing groups to be // static, and you can even request fewer groups than what's there. So @@ -1952,7 +1952,7 @@ impl<'h> core::fmt::Debug for Captures<'h> { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "{}", self.0)?; if let Some(name) = self.1 { - write!(f, "/{:?}", name)?; + write!(f, "/{name:?}")?; } Ok(()) } diff --git a/tests/misc.rs b/tests/misc.rs index 91e7d2898..c04c9c9fe 100644 --- a/tests/misc.rs +++ b/tests/misc.rs @@ -10,7 +10,7 @@ macro_rules! regex { fn unclosed_group_error() { let err = Regex::new(r"(").unwrap_err(); let msg = err.to_string(); - assert!(msg.contains("unclosed group"), "error message: {:?}", msg); + assert!(msg.contains("unclosed group"), "error message: {msg:?}"); } #[test] diff --git a/tests/suite_bytes.rs b/tests/suite_bytes.rs index 106d99808..784b1a47a 100644 --- a/tests/suite_bytes.rs +++ b/tests/suite_bytes.rs @@ -36,7 +36,7 @@ fn run_test(re: &Regex, test: &RegexTest) -> TestResult { .map(|caps| testify_captures(&caps)); TestResult::captures(it) } - name => TestResult::fail(&format!("unrecognized test name: {}", name)), + name => TestResult::fail(&format!("unrecognized test name: {name}")), } } diff --git a/tests/suite_bytes_set.rs b/tests/suite_bytes_set.rs index 899d24c17..9b75f8da1 100644 --- a/tests/suite_bytes_set.rs +++ b/tests/suite_bytes_set.rs @@ -20,7 +20,7 @@ fn run_test(re: &RegexSet, test: &RegexTest) -> TestResult { match test.additional_name() { "is_match" => TestResult::matched(re.is_match(test.haystack())), "which" => TestResult::which(re.matches(test.haystack()).iter()), - name => TestResult::fail(&format!("unrecognized test name: {}", name)), + name => TestResult::fail(&format!("unrecognized test name: {name}")), } } diff --git a/tests/suite_string.rs b/tests/suite_string.rs index 1e5bf0bb3..c8fb3d08a 100644 --- a/tests/suite_string.rs +++ b/tests/suite_string.rs @@ -23,8 +23,7 @@ fn run_test(re: &Regex, test: &RegexTest) -> TestResult { Ok(hay) => hay, Err(err) => { return TestResult::fail(&format!( - "haystack is not valid UTF-8: {}", - err + "haystack is not valid UTF-8: {err}" )); } }; @@ -45,7 +44,7 @@ fn run_test(re: &Regex, test: &RegexTest) -> TestResult { .map(|caps| testify_captures(&caps)); TestResult::captures(it) } - name => TestResult::fail(&format!("unrecognized test name: {}", name)), + name => TestResult::fail(&format!("unrecognized test name: {name}")), } } diff --git a/tests/suite_string_set.rs b/tests/suite_string_set.rs index dffdc7081..49b87ec45 100644 --- a/tests/suite_string_set.rs +++ b/tests/suite_string_set.rs @@ -21,15 +21,14 @@ fn run_test(re: &RegexSet, test: &RegexTest) -> TestResult { Ok(hay) => hay, Err(err) => { return TestResult::fail(&format!( - "haystack is not valid UTF-8: {}", - err + "haystack is not valid UTF-8: {err}" )); } }; match test.additional_name() { "is_match" => TestResult::matched(re.is_match(hay)), "which" => TestResult::which(re.matches(hay).iter()), - name => TestResult::fail(&format!("unrecognized test name: {}", name)), + name => TestResult::fail(&format!("unrecognized test name: {name}")), } }