mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-17 09:28:25 +01:00
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
This commit is contained in:
parent
7fe4bfaacb
commit
5ea7cb7a05
1 changed files with 2 additions and 15 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue