From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 1E5A0676CD for ; Tue, 12 Jan 2021 14:58:50 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1C6382703D for ; Tue, 12 Jan 2021 14:58:50 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 2E14B26FFD for ; Tue, 12 Jan 2021 14:58:49 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id ED11045F58 for ; Tue, 12 Jan 2021 14:58:48 +0100 (CET) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Tue, 12 Jan 2021 14:58:29 +0100 Message-Id: <20210112135830.2798301-20-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210112135830.2798301-1-f.gruenbichler@proxmox.com> References: <20210112135830.2798301-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.027 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [util.rs, lib.rs] Subject: [pbs-devel] [RFC pxar 2/3] clippy: use matches! instead of match X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jan 2021 13:58:50 -0000 Signed-off-by: Fabian Grünbichler --- 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