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:
Thayne McCombs 2021-12-07 09:04:17 -08:00 committed by GitHub
parent 7fe4bfaacb
commit 5ea7cb7a05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 15 deletions

View File

@ -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()