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/file.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/file.rs')
-rw-r--r-- | src/fs/file.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/fs/file.rs b/src/fs/file.rs index c22b815..5657588 100644 --- a/src/fs/file.rs +++ b/src/fs/file.rs @@ -417,9 +417,9 @@ impl<'dir> File<'dir> { /// /// This will always return `false` if the file has no extension. pub fn extension_is_one_of(&self, choices: &[&str]) -> bool { - match self.ext { - Some(ref ext) => choices.contains(&&ext[..]), - None => false, + match &self.ext { + Some(ext) => choices.contains(&&ext[..]), + None => false, } } @@ -463,10 +463,7 @@ impl<'dir> FileTarget<'dir> { /// Whether this link doesn’t lead to a file, for whatever reason. This /// gets used to determine how to highlight the link in grid views. pub fn is_broken(&self) -> bool { - match *self { - FileTarget::Ok(_) => false, - FileTarget::Broken(_) | FileTarget::Err(_) => true, - } + matches!(self, Self::Broken(_) | Self::Err(_)) } } |