From 5ea7cb7a05db0712f8d7073f0aa98a16bdcf7f7d Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Tue, 7 Dec 2021 09:04:17 -0800 Subject: [PATCH] A couple of minor recommendations from the Code Quality action (#903) use derive for a Default impl, and use a function directly instead of needlessly wrapping it in a closure --- src/filetypes.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/filetypes.rs b/src/filetypes.rs index 10872a0..fc0962d 100644 --- a/src/filetypes.rs +++ b/src/filetypes.rs @@ -2,6 +2,7 @@ use crate::filesystem; use crate::walk; /// Whether or not to show +#[derive(Default)] pub struct FileTypes { pub files: bool, pub directories: bool, @@ -12,20 +13,6 @@ pub struct FileTypes { pub empty_only: bool, } -impl Default for FileTypes { - fn default() -> FileTypes { - FileTypes { - files: false, - directories: false, - symlinks: false, - sockets: false, - pipes: false, - executables_only: false, - empty_only: false, - } - } -} - impl FileTypes { pub fn should_ignore(&self, entry: &walk::DirEntry) -> bool { if let Some(ref entry_type) = entry.file_type() { @@ -37,7 +24,7 @@ impl FileTypes { || (self.executables_only && !entry .metadata() - .map(|m| filesystem::is_executable(m)) + .map(filesystem::is_executable) .unwrap_or(false)) || (self.empty_only && !filesystem::is_empty(entry)) || !(entry_type.is_file()