Skip to content
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
16 changes: 6 additions & 10 deletions src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct Params {

#[inline]
fn usage_string(executable: &str) -> String {
format!("Usage: {} <from> <to>", executable)
format!("Usage: {executable} <from> <to>")
}

#[cfg(not(target_os = "windows"))]
Expand Down Expand Up @@ -75,8 +75,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
Err(e) if *e.kind() == std::num::IntErrorKind::PosOverflow => usize::MAX,
Err(_) => {
return Err(format!(
"{}: invalid --ignore-initial value '{}'",
executable_str, skip_desc
"{executable_str}: invalid --ignore-initial value '{skip_desc}'"
))
}
};
Expand All @@ -103,8 +102,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
"Y" => usize::MAX, // 1_208_925_819_614_629_174_706_176,
_ => {
return Err(format!(
"{}: invalid --ignore-initial value '{}'",
executable_str, skip_desc
"{executable_str}: invalid --ignore-initial value '{skip_desc}'"
));
}
};
Expand Down Expand Up @@ -170,8 +168,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
Err(e) if *e.kind() == std::num::IntErrorKind::PosOverflow => usize::MAX,
Err(_) => {
return Err(format!(
"{}: invalid --bytes value '{}'",
executable_str, max_bytes
"{executable_str}: invalid --bytes value '{max_bytes}'"
))
}
};
Expand Down Expand Up @@ -210,7 +207,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
std::process::exit(0);
}
if param_str.starts_with('-') {
return Err(format!("Unknown option: {:?}", param));
return Err(format!("Unknown option: {param:?}"));
}
if from.is_none() {
from = Some(param);
Expand All @@ -236,8 +233,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu

if params.quiet && params.verbose {
return Err(format!(
"{}: options -l and -s are incompatible",
executable_str
"{executable_str}: options -l and -s are incompatible"
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn main() -> ExitCode {
Some("diff") => diff::main(args),
Some("cmp") => cmp::main(args),
Some(name) => {
eprintln!("{}: utility not supported", name);
eprintln!("{name}: utility not supported");
ExitCode::from(2)
}
None => second_arg_error(exe_name),
Expand Down
2 changes: 1 addition & 1 deletion src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
Err(error) => return Err(error),
}
if param.to_string_lossy().starts_with('-') {
return Err(format!("Unknown option: {:?}", param));
return Err(format!("Unknown option: {param:?}"));
}
if from.is_none() {
from = Some(param);
Expand Down
11 changes: 4 additions & 7 deletions src/side_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ mod tests {
let symbol = b'<'; // impossible case, just to use different symbol
let mut buf = vec![];
push_output(left_ln, right_ln, symbol, &mut buf, &config).unwrap();
assert_eq!(buf, format!("data\t\t\t\t\t\t\t <\n").as_bytes());
assert_eq!(buf, "data\t\t\t\t\t\t\t <\n".as_bytes());
}

#[test]
Expand Down Expand Up @@ -948,12 +948,9 @@ mod tests {
let symbol = b' ';
let mut buf = vec![];
push_output(left_ln, right_ln, symbol, &mut buf, &config).unwrap();
let expected_left = format!("áéíóú\t\t\t\t\t\t\t\t");
let expected_left = "áéíóú\t\t\t\t\t\t\t\t";
let expected_right = "😀😃😄";
assert_eq!(
buf,
format!("{}{}\n", expected_left, expected_right).as_bytes()
);
assert_eq!(buf, format!("{expected_left}{expected_right}\n").as_bytes());
}
}

Expand All @@ -976,7 +973,7 @@ mod tests {
}
}

fn contains_string(vec: &Vec<u8>, s: &str) -> usize {
fn contains_string(vec: &[u8], s: &str) -> usize {
let pattern = s.as_bytes();
vec.windows(pattern.len()).filter(|s| s == &pattern).count()
}
Expand Down
Loading