diff options
author | Benjamin Sago <ogham@bsago.me> | 2020-10-10 15:30:19 +0100 |
---|---|---|
committer | Benjamin Sago <ogham@bsago.me> | 2020-10-10 15:30:19 +0100 |
commit | f0c139ca682178e5cf4e735c0d7621719e73f6a0 (patch) | |
tree | 466fe7270a5dc7360f494a0e5c8c9b24d576c0cf /src/fs/dir_action.rs | |
parent | 70a30ed683ecc88304c6b2d66b6d34d61a1dd072 (diff) |
Better referencing
This commit makes changes to the way variables are referenced:
• Make types Copy when possible
• Make methods take `self` instead of `&self` where possible (trivially_copy_pass_by_ref)
• Remove unnecessary borrowing (needless_ref)
• Remove unnecessary cloning (clone_on_copy)
• Remove `ref` from match arms where possible (new Rust match ergonomics)
Diffstat (limited to 'src/fs/dir_action.rs')
-rw-r--r-- | src/fs/dir_action.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/fs/dir_action.rs b/src/fs/dir_action.rs index d72db88..26e78d3 100644 --- a/src/fs/dir_action.rs +++ b/src/fs/dir_action.rs @@ -39,19 +39,19 @@ pub enum DirAction { impl DirAction { /// Gets the recurse options, if this dir action has any. - pub fn recurse_options(&self) -> Option<RecurseOptions> { - match *self { - Self::Recurse(o) => Some(o), - _ => None, + pub fn recurse_options(self) -> Option<RecurseOptions> { + match self { + Self::Recurse(o) => Some(o), + _ => None, } } /// Whether to treat directories as regular files or not. - pub fn treat_dirs_as_files(&self) -> bool { - match *self { + pub fn treat_dirs_as_files(self) -> bool { + match self { Self::AsFile => true, Self::Recurse(o) => o.tree, - _ => false, + _ => false, } } } @@ -73,10 +73,10 @@ pub struct RecurseOptions { impl RecurseOptions { /// Returns whether a directory of the given depth would be too deep. - pub fn is_too_deep(&self, depth: usize) -> bool { + pub fn is_too_deep(self, depth: usize) -> bool { match self.max_depth { - None => false, - Some(d) => d <= depth + None => false, + Some(d) => d <= depth } } } |