Use variables directly inside format strings

Most systems should have an up to date Rust compiler by now, so we should be
fine.
This commit is contained in:
Henrik Friedrichsen
2023-02-06 20:06:25 +01:00
parent 2fe3b056bf
commit 8222f1b2e4
17 changed files with 34 additions and 40 deletions

View File

@@ -90,12 +90,12 @@ pub enum SeekDirection {
impl fmt::Display for SeekDirection {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let repr = match self {
SeekDirection::Absolute(pos) => format!("{}", pos),
SeekDirection::Absolute(pos) => format!("{pos}"),
SeekDirection::Relative(delta) => {
format!("{}{}", if delta > &0 { "+" } else { "" }, delta)
}
};
write!(f, "{}", repr)
write!(f, "{repr}")
}
}
@@ -113,7 +113,7 @@ impl fmt::Display for InsertSource {
InsertSource::Clipboard => "".into(),
InsertSource::Input(url) => url.to_string(),
};
write!(f, "{}", repr)
write!(f, "{repr}")
}
}
@@ -315,12 +315,12 @@ impl fmt::Display for CommandParseError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use CommandParseError::*;
let formatted = match self {
NoSuchCommand { cmd } => format!("No such command \"{}\"", cmd),
NoSuchCommand { cmd } => format!("No such command \"{cmd}\""),
InsufficientArgs { cmd, hint } => {
if let Some(hint_str) = hint {
format!("\"{}\" requires additional arguments: {}", cmd, hint_str)
format!("\"{cmd}\" requires additional arguments: {hint_str}")
} else {
format!("\"{}\" requires additional arguments", cmd)
format!("\"{cmd}\" requires additional arguments")
}
}
BadEnumArg { arg, accept } => {
@@ -330,9 +330,9 @@ impl fmt::Display for CommandParseError {
accept.join("|")
)
}
ArgParseError { arg, err } => format!("Error with argument \"{}\": {}", arg, err),
ArgParseError { arg, err } => format!("Error with argument \"{arg}\": {err}"),
};
write!(f, "{}", formatted)
write!(f, "{formatted}")
}
}