[pbs-devel] [RFC pxar 2/3] clippy: use matches! instead of match
Fabian Grünbichler
f.gruenbichler at proxmox.com
Tue Jan 12 14:58:29 CET 2021
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
src/lib.rs | 25 +++++--------------------
src/util.rs | 7 ++-----
2 files changed, 7 insertions(+), 25 deletions(-)
diff --git a/src/lib.rs b/src/lib.rs
index 4036fd6..ba707da 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -453,42 +453,27 @@ impl Entry {
impl Entry {
/// Check whether this is a directory.
pub fn is_dir(&self) -> bool {
- match self.kind {
- EntryKind::Directory { .. } => true,
- _ => false,
- }
+ matches!(self.kind, EntryKind::Directory)
}
/// Check whether this is a symbolic link.
pub fn is_symlink(&self) -> bool {
- match self.kind {
- EntryKind::Symlink(_) => true,
- _ => false,
- }
+ matches!(self.kind, EntryKind::Symlink(_))
}
/// Check whether this is a hard link.
pub fn is_hardlink(&self) -> bool {
- match self.kind {
- EntryKind::Hardlink(_) => true,
- _ => false,
- }
+ matches!(self.kind, EntryKind::Hardlink(_))
}
/// Check whether this is a device node.
pub fn is_device(&self) -> bool {
- match self.kind {
- EntryKind::Device(_) => true,
- _ => false,
- }
+ matches!(self.kind, EntryKind::Device(_))
}
/// Check whether this is a regular file.
pub fn is_regular_file(&self) -> bool {
- match self.kind {
- EntryKind::File { .. } => true,
- _ => false,
- }
+ matches!(self.kind, EntryKind::File { .. })
}
/// Get the file size if this is a regular file, or `None`.
diff --git a/src/util.rs b/src/util.rs
index 652008b..5740963 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -55,8 +55,7 @@ mod consts {
}
pub fn is_virtual_file_system(magic: i64) -> bool {
- match magic {
- consts::BINFMTFS_MAGIC
+ matches!(magic, consts::BINFMTFS_MAGIC
| consts::CGROUP2_SUPER_MAGIC
| consts::CGROUP_SUPER_MAGIC
| consts::CONFIGFS_MAGIC
@@ -73,9 +72,7 @@ pub fn is_virtual_file_system(magic: i64) -> bool {
| consts::SECURITYFS_MAGIC
| consts::SELINUX_MAGIC
| consts::SMACK_MAGIC
- | consts::SYSFS_MAGIC => true,
- _ => false,
- }
+ | consts::SYSFS_MAGIC)
}
/// Helper function to extract file names from binary archive.
--
2.20.1
More information about the pbs-devel
mailing list