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

Embed values in format strings #38

Merged
merged 1 commit into from
Jan 28, 2023
Merged
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
4 changes: 2 additions & 2 deletions src/canonicalize_and_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn canonicalize_protocol(value: &str) -> Result<String, Error> {
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)
}
Expand Down Expand Up @@ -92,7 +92,7 @@ pub fn canonicalize_pathname(value: &str) -> Result<String, Error> {
}
let leading_slash = value.starts_with('/');
let modified_value = if !leading_slash {
format!("/-{}", value)
format!("/-{value}")
} else {
value.to_string()
};
Expand Down
2 changes: 1 addition & 1 deletion src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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})"));
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ mod tests {
);

if let Some(reason) = case.skip {
println!("🟠 Skipping: {}", reason);
println!("🟠 Skipping: {reason}");
return;
}

Expand Down