From 5dc8d3efed9a913421b6feb477cf039b199ba110 Mon Sep 17 00:00:00 2001 From: figsoda Date: Mon, 3 Oct 2022 18:48:08 -0400 Subject: [PATCH] fix: apply clippy lints --- src/archive/zip.rs | 4 ++-- src/commands/decompress.rs | 8 ++++---- src/commands/list.rs | 2 +- src/utils/fs.rs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/archive/zip.rs b/src/archive/zip.rs index 9e0e3a5..77b9684 100644 --- a/src/archive/zip.rs +++ b/src/archive/zip.rs @@ -61,7 +61,7 @@ where _is_file @ false => { if let Some(path) = file_path.parent() { if !path.exists() { - fs::create_dir_all(&path)?; + fs::create_dir_all(path)?; } } let file_path = strip_cur_dir(file_path.as_path()); @@ -69,7 +69,7 @@ where // same reason is in _is_dir: long, often not needed text info!(@display_handle, inaccessible, "{:?} extracted. ({})", file_path.display(), Bytes::new(file.size())); - let mut output_file = fs::File::create(&file_path)?; + let mut output_file = fs::File::create(file_path)?; io::copy(&mut file, &mut output_file)?; #[cfg(unix)] diff --git a/src/commands/decompress.rs b/src/commands/decompress.rs index bdfde34..d918fe9 100644 --- a/src/commands/decompress.rs +++ b/src/commands/decompress.rs @@ -34,7 +34,7 @@ pub fn decompress_file( ) -> crate::Result<()> { assert!(output_dir.exists()); let total_input_size = input_file_path.metadata().expect("file exists").len(); - let reader = fs::File::open(&input_file_path)?; + let reader = fs::File::open(input_file_path)?; // Zip archives are special, because they require io::Seek, so it requires it's logic separated // from decoder chaining. @@ -204,10 +204,10 @@ fn smart_unpack( .unwrap_or(&mut io::stdout()), )?; - let root_contains_only_one_element = fs::read_dir(&temp_dir_path)?.count() == 1; + let root_contains_only_one_element = fs::read_dir(temp_dir_path)?.count() == 1; if root_contains_only_one_element { // Only one file in the root directory, so we can just move it to the output directory - let file = fs::read_dir(&temp_dir_path)?.next().expect("item exists")?; + let file = fs::read_dir(temp_dir_path)?.next().expect("item exists")?; let file_path = file.path(); let file_name = file_path .file_name() @@ -231,7 +231,7 @@ fn smart_unpack( if !utils::clear_path(output_file_path, question_policy)? { return Ok(ControlFlow::Break(())); } - fs::rename(&temp_dir_path, &output_file_path)?; + fs::rename(temp_dir_path, output_file_path)?; info!( accessible, "Successfully moved {} to {}.", diff --git a/src/commands/list.rs b/src/commands/list.rs index a5832d5..dc28be5 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs @@ -21,7 +21,7 @@ pub fn list_archive_contents( list_options: ListOptions, question_policy: QuestionPolicy, ) -> crate::Result<()> { - let reader = fs::File::open(&archive_path)?; + let reader = fs::File::open(archive_path)?; // Zip archives are special, because they require io::Seek, so it requires it's logic separated // from decoder chaining. diff --git a/src/utils/fs.rs b/src/utils/fs.rs index 96f5523..ac514f7 100644 --- a/src/utils/fs.rs +++ b/src/utils/fs.rs @@ -94,7 +94,7 @@ pub fn try_infer_extension(path: &Path) -> Option { let mut buf = [0; 270]; // Error cause will be ignored, so use std::fs instead of fs_err - let result = std::fs::File::open(&path).map(|mut file| file.read(&mut buf)); + let result = std::fs::File::open(path).map(|mut file| file.read(&mut buf)); // In case of file open or read failure, could not infer a extension if result.is_err() {