refactor/cat ~ fix cargo clippy complaint (clippy::needless_borrow)

This commit is contained in:
Roy Ivy III 2021-06-05 21:10:13 -05:00
parent 777e3906f8
commit c115ad4274

View file

@ -295,7 +295,7 @@ fn cat_handle<R: Read>(
if options.can_write_fast() { if options.can_write_fast() {
write_fast(handle) write_fast(handle)
} else { } else {
write_lines(handle, &options, state) write_lines(handle, options, state)
} }
} }
@ -308,7 +308,7 @@ fn cat_path(path: &str, options: &OutputOptions, state: &mut OutputState) -> Cat
reader: stdin, reader: stdin,
is_interactive: is_stdin_interactive(), is_interactive: is_stdin_interactive(),
}; };
return cat_handle(&mut handle, &options, state); return cat_handle(&mut handle, options, state);
} }
match get_input_type(path)? { match get_input_type(path)? {
InputType::Directory => Err(CatError::IsDirectory), InputType::Directory => Err(CatError::IsDirectory),
@ -322,7 +322,7 @@ fn cat_path(path: &str, options: &OutputOptions, state: &mut OutputState) -> Cat
reader: socket, reader: socket,
is_interactive: false, is_interactive: false,
}; };
cat_handle(&mut handle, &options, state) cat_handle(&mut handle, options, state)
} }
_ => { _ => {
let file = File::open(path)?; let file = File::open(path)?;
@ -332,7 +332,7 @@ fn cat_path(path: &str, options: &OutputOptions, state: &mut OutputState) -> Cat
reader: file, reader: file,
is_interactive: false, is_interactive: false,
}; };
cat_handle(&mut handle, &options, state) cat_handle(&mut handle, options, state)
} }
} }
} }
@ -345,7 +345,7 @@ fn cat_files(files: Vec<String>, options: &OutputOptions) -> Result<(), u32> {
}; };
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) {
show_error!("{}: {}", path, err); show_error!("{}: {}", path, err);
error_count += 1; error_count += 1;
} }