Skip to content

Commit 3654b82

Browse files
authored
Merge pull request #123 from cakebaker/clippy_fix_warnings
clippy: fix warnings
2 parents 168dae3 + 7df0239 commit 3654b82

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

src/cmp.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct Params {
3535

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

4141
#[cfg(not(target_os = "windows"))]
@@ -75,8 +75,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
7575
Err(e) if *e.kind() == std::num::IntErrorKind::PosOverflow => usize::MAX,
7676
Err(_) => {
7777
return Err(format!(
78-
"{}: invalid --ignore-initial value '{}'",
79-
executable_str, skip_desc
78+
"{executable_str}: invalid --ignore-initial value '{skip_desc}'"
8079
))
8180
}
8281
};
@@ -103,8 +102,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
103102
"Y" => usize::MAX, // 1_208_925_819_614_629_174_706_176,
104103
_ => {
105104
return Err(format!(
106-
"{}: invalid --ignore-initial value '{}'",
107-
executable_str, skip_desc
105+
"{executable_str}: invalid --ignore-initial value '{skip_desc}'"
108106
));
109107
}
110108
};
@@ -170,8 +168,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
170168
Err(e) if *e.kind() == std::num::IntErrorKind::PosOverflow => usize::MAX,
171169
Err(_) => {
172170
return Err(format!(
173-
"{}: invalid --bytes value '{}'",
174-
executable_str, max_bytes
171+
"{executable_str}: invalid --bytes value '{max_bytes}'"
175172
))
176173
}
177174
};
@@ -210,7 +207,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
210207
std::process::exit(0);
211208
}
212209
if param_str.starts_with('-') {
213-
return Err(format!("Unknown option: {:?}", param));
210+
return Err(format!("Unknown option: {param:?}"));
214211
}
215212
if from.is_none() {
216213
from = Some(param);
@@ -236,8 +233,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
236233

237234
if params.quiet && params.verbose {
238235
return Err(format!(
239-
"{}: options -l and -s are incompatible",
240-
executable_str
236+
"{executable_str}: options -l and -s are incompatible"
241237
));
242238
}
243239

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn main() -> ExitCode {
7373
Some("diff") => diff::main(args),
7474
Some("cmp") => cmp::main(args),
7575
Some(name) => {
76-
eprintln!("{}: utility not supported", name);
76+
eprintln!("{name}: utility not supported");
7777
ExitCode::from(2)
7878
}
7979
None => second_arg_error(exe_name),

src/params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
195195
Err(error) => return Err(error),
196196
}
197197
if param.to_string_lossy().starts_with('-') {
198-
return Err(format!("Unknown option: {:?}", param));
198+
return Err(format!("Unknown option: {param:?}"));
199199
}
200200
if from.is_none() {
201201
from = Some(param);

src/side_diff.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ mod tests {
901901
let symbol = b'<'; // impossible case, just to use different symbol
902902
let mut buf = vec![];
903903
push_output(left_ln, right_ln, symbol, &mut buf, &config).unwrap();
904-
assert_eq!(buf, format!("data\t\t\t\t\t\t\t <\n").as_bytes());
904+
assert_eq!(buf, "data\t\t\t\t\t\t\t <\n".as_bytes());
905905
}
906906

907907
#[test]
@@ -948,12 +948,9 @@ mod tests {
948948
let symbol = b' ';
949949
let mut buf = vec![];
950950
push_output(left_ln, right_ln, symbol, &mut buf, &config).unwrap();
951-
let expected_left = format!("áéíóú\t\t\t\t\t\t\t\t");
951+
let expected_left = "áéíóú\t\t\t\t\t\t\t\t";
952952
let expected_right = "😀😃😄";
953-
assert_eq!(
954-
buf,
955-
format!("{}{}\n", expected_left, expected_right).as_bytes()
956-
);
953+
assert_eq!(buf, format!("{expected_left}{expected_right}\n").as_bytes());
957954
}
958955
}
959956

@@ -976,7 +973,7 @@ mod tests {
976973
}
977974
}
978975

979-
fn contains_string(vec: &Vec<u8>, s: &str) -> usize {
976+
fn contains_string(vec: &[u8], s: &str) -> usize {
980977
let pattern = s.as_bytes();
981978
vec.windows(pattern.len()).filter(|s| s == &pattern).count()
982979
}

0 commit comments

Comments
 (0)