mirror of
https://github.com/sharkdp/fd.git
synced 2024-09-28 21:11:30 +02: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
@ -2,6 +2,7 @@ use crate::filesystem;
|
|||||||
use crate::walk;
|
use crate::walk;
|
||||||
|
|
||||||
/// Whether or not to show
|
/// Whether or not to show
|
||||||
|
#[derive(Default)]
|
||||||
pub struct FileTypes {
|
pub struct FileTypes {
|
||||||
pub files: bool,
|
pub files: bool,
|
||||||
pub directories: bool,
|
pub directories: bool,
|
||||||
@ -12,20 +13,6 @@ pub struct FileTypes {
|
|||||||
pub empty_only: bool,
|
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 {
|
impl FileTypes {
|
||||||
pub fn should_ignore(&self, entry: &walk::DirEntry) -> bool {
|
pub fn should_ignore(&self, entry: &walk::DirEntry) -> bool {
|
||||||
if let Some(ref entry_type) = entry.file_type() {
|
if let Some(ref entry_type) = entry.file_type() {
|
||||||
@ -37,7 +24,7 @@ impl FileTypes {
|
|||||||
|| (self.executables_only
|
|| (self.executables_only
|
||||||
&& !entry
|
&& !entry
|
||||||
.metadata()
|
.metadata()
|
||||||
.map(|m| filesystem::is_executable(m))
|
.map(filesystem::is_executable)
|
||||||
.unwrap_or(false))
|
.unwrap_or(false))
|
||||||
|| (self.empty_only && !filesystem::is_empty(entry))
|
|| (self.empty_only && !filesystem::is_empty(entry))
|
||||||
|| !(entry_type.is_file()
|
|| !(entry_type.is_file()
|
||||||
|
Loading…
Reference in New Issue
Block a user