From b79251382b3b084d8c5ac19858ddf7426b3e655c Mon Sep 17 00:00:00 2001 From: woxtu Date: Sun, 29 Jan 2023 06:25:34 +0900 Subject: [PATCH] chore: embed values in format strings (#38) --- src/canonicalize_and_process.rs | 4 ++-- src/component.rs | 2 +- src/error.rs | 10 +++++----- src/lib.rs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/canonicalize_and_process.rs b/src/canonicalize_and_process.rs index 8e255f7..6a73fab 100644 --- a/src/canonicalize_and_process.rs +++ b/src/canonicalize_and_process.rs @@ -13,7 +13,7 @@ pub fn canonicalize_protocol(value: &str) -> Result { if value.is_empty() { return Ok(String::new()); } - url::Url::parse(&format!("{}://dummy.test", value)) + url::Url::parse(&format!("{value}://dummy.test")) .map(|url| url.scheme().to_owned()) .map_err(Error::Url) } @@ -92,7 +92,7 @@ pub fn canonicalize_pathname(value: &str) -> Result { } let leading_slash = value.starts_with('/'); let modified_value = if !leading_slash { - format!("/-{}", value) + format!("/-{value}") } else { value.to_string() }; diff --git a/src/component.rs b/src/component.rs index 830647a..e907458 100644 --- a/src/component.rs +++ b/src/component.rs @@ -238,7 +238,7 @@ fn generate_pattern_string(part_list: &[&Part], options: &Options) -> String { { result.push('*'); } else { - result.push_str(&format!("({})", FULL_WILDCARD_REGEXP_VALUE)); + result.push_str(&format!("({FULL_WILDCARD_REGEXP_VALUE})")); } } } diff --git a/src/error.rs b/src/error.rs index b6277f0..b6bb8e2 100644 --- a/src/error.rs +++ b/src/error.rs @@ -13,10 +13,10 @@ pub enum Error { )] BaseUrlWithInit, - #[display(fmt = "tokenizer error: {} (at char {})", _0, _1)] + #[display(fmt = "tokenizer error: {_0} (at char {_1})")] Tokenizer(TokenizerError, usize), - #[display(fmt = "parser error: {}", _0)] + #[display(fmt = "parser error: {_0}")] Parser(ParserError), Url(url::ParseError), @@ -39,15 +39,15 @@ pub enum TokenizerError { IncompleteEscapeCode, #[display(fmt = "invalid name; must be at least length 1")] InvalidName, - #[display(fmt = "invalid regex: {}", _0)] + #[display(fmt = "invalid regex: {_0}")] InvalidRegex(&'static str), } #[derive(Debug, Display)] pub enum ParserError { - #[display(fmt = "expected token {}, found '{}' of type {}", _0, _2, _1)] + #[display(fmt = "expected token {_0}, found '{_2}' of type {_1}")] ExpectedToken(TokenType, TokenType, String), - #[display(fmt = "pattern contains duplicate name {}", _0)] + #[display(fmt = "pattern contains duplicate name {_0}")] DuplicateName(String), } diff --git a/src/lib.rs b/src/lib.rs index e4fb5b4..ed688cd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -592,7 +592,7 @@ mod tests { ); if let Some(reason) = case.skip { - println!("🟠 Skipping: {}", reason); + println!("🟠 Skipping: {reason}"); return; }