Skip to content
Myr

A couple of minor recommendations from the Code Quality action (#903)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

use derive for a Default impl, and use a function directly instead of needlessly wrapping it in a closure

authored by Thayne McCombs · committed by GitHub · parent 7fe4bfa · Browse files · 1 file+2 added−15 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−15 removed

  • other:+2 added−15 removed

1 file+2 added−15 removed

modified:src/filetypes.rs+2 added-15 removed
1use crate::filesystem;2use crate::walk;34/// Whether or not to show5#[derive(Default)]6pub struct FileTypes {7 pub files: bool,8 pub directories: bool,9 pub symlinks: bool,
2 unmodified lines
12 pub executables_only: bool,13 pub empty_only: bool,14}1515impl Default for FileTypes {16 fn default() -> FileTypes {17 FileTypes {18 files: false,19 directories: false,20 symlinks: false,21 sockets: false,22 pipes: false,23 executables_only: false,24 empty_only: false,25 }26 }27}2816impl FileTypes {17 pub fn should_ignore(&self, entry: &walk::DirEntry) -> bool {18 if let Some(ref entry_type) = entry.file_type() {19 (!self.files && entry_type.is_file())
3 unmodified lines
23 || (!self.pipes && filesystem::is_pipe(*entry_type))24 || (self.executables_only25 && !entry26 .metadata()40 .map(|m| filesystem::is_executable(m))27 .map(filesystem::is_executable)28 .unwrap_or(false))29 || (self.empty_only && !filesystem::is_empty(entry))30 || !(entry_type.is_file()31 || entry_type.is_dir()
8 unmodified lines