1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-13 10:37:58 +00:00

correct clippy issues, RustFmt

This commit is contained in:
Felipe Lema 2021-08-01 23:55:30 -04:00
parent 2106ddd088
commit 5646c81332

View file

@ -343,24 +343,23 @@ fn cat_files(files: Vec<String>, options: &OutputOptions) -> UResult<()> {
line_number: 1, line_number: 1,
at_line_start: true, at_line_start: true,
}; };
let mut error_messages : Vec<String> = Vec::new(); let mut error_messages: Vec<String> = Vec::new();
for path in &files { for path in &files {
if let Err(err) = cat_path(path, options, &mut state) { if let Err(err) = cat_path(path, options, &mut state) {
error_messages.push( error_messages.push(format!("{}: {}", path, err));
format!("{}: {}", path, err));
} }
} }
if error_messages.len() == 0 { if error_messages.is_empty() {
Ok(()) Ok(())
} else { } else {
// each next line is expected to display "cat: …" // each next line is expected to display "cat: …"
let line_joiner = format!("\n{}: ", let line_joiner = format!("\n{}: ", executable!());
executable!()).to_owned();
Err(uucore::error::USimpleError::new( Err(uucore::error::USimpleError::new(
error_messages.len() as i32, error_messages.len() as i32,
error_messages.join(&line_joiner).into())) error_messages.join(&line_joiner),
))
} }
} }