From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ronja.mits.lan by ronja.mits.lan with LMTP id MIYKK0USfGYDIwAAxxbTJA (envelope-from ); Wed, 26 Jun 2024 15:06:13 +0200 Received: from proxmox-new.maurer-it.com (unknown [192.168.2.33]) by ronja.mits.lan (Postfix) with ESMTPS id 93A78F6463A; Wed, 26 Jun 2024 15:06:13 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 770C948725; Wed, 26 Jun 2024 15:06:13 +0200 (CEST) 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 (4096 bits)) (No client certificate requested) by proxmox-new.maurer-it.com (Proxmox) with ESMTPS; Wed, 26 Jun 2024 15:06:12 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2B8331ACC; Wed, 26 Jun 2024 15:06:09 +0200 (CEST) From: Maximiliano Sandoval To: pbs-devel@lists.proxmox.com Date: Wed, 26 Jun 2024 15:05:59 +0200 Message-Id: <20240626130603.538973-2-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626130603.538973-1-m.sandoval@proxmox.com> References: <20240626130603.538973-1-m.sandoval@proxmox.com> MIME-Version: 1.0 Subject: [pbs-devel] [PATCH backup v2 2/6] replace get(key).is_none() with !contains_key() 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" X-SPAM-LEVEL: Spam detection results: 0 DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods MAILING_LIST_MULTI -2 Multiple indicators imply a widely-seen list manager RAZOR2_CF_RANGE_51_100 2.43 Razor2 gives confidence level above 50% RAZOR2_CHECK 1.729 Listed in Razor2 (http://razor.sf.net/) 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_NONE 0.001 SPF: sender does not publish an SPF Record Fixes the clippy warning: warning: unnecessary use of `get(&user2).is_none()` --> pbs-config/src/acl.rs:1067:36 | 1067 | assert!(node.users.get(&user2).is_none()); | -----------^^^^^^^^^^^^^^^^^^^^^ | | | help: replace it with: `!node.users.contains_key(&user2)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check Signed-off-by: Maximiliano Sandoval --- pbs-config/src/acl.rs | 4 ++-- pbs-config/src/network/parser.rs | 2 +- pbs-config/src/user.rs | 2 +- src/api2/access/acl.rs | 2 +- src/api2/tape/drive.rs | 4 ++-- src/config/acme/plugin.rs | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pbs-config/src/acl.rs b/pbs-config/src/acl.rs index 8a1423cc..8b6215ef 100644 --- a/pbs-config/src/acl.rs +++ b/pbs-config/src/acl.rs @@ -1047,7 +1047,7 @@ acl:1:/storage/store1:user1@pbs:DatastoreBackup let node = tree.find_node(path); assert!(node.is_some()); if let Some(node) = node { - assert!(node.users.get(&user1).is_none()); + assert!(!node.users.contains_key(&user1)); } } for path in &user2_paths { @@ -1064,7 +1064,7 @@ acl:1:/storage/store1:user1@pbs:DatastoreBackup let node = tree.find_node(path); assert!(node.is_some()); if let Some(node) = node { - assert!(node.users.get(&user2).is_none()); + assert!(!node.users.contains_key(&user2)); } } diff --git a/pbs-config/src/network/parser.rs b/pbs-config/src/network/parser.rs index 2158a04f..7498dd35 100644 --- a/pbs-config/src/network/parser.rs +++ b/pbs-config/src/network/parser.rs @@ -585,7 +585,7 @@ impl NetworkParser { } } - if config.interfaces.get("lo").is_none() { + if !config.interfaces.contains_key("lo") { let mut interface = Interface::new(String::from("lo")); set_method_v4(&mut interface, NetworkConfigMethod::Loopback)?; interface.interface_type = NetworkInterfaceType::Loopback; diff --git a/pbs-config/src/user.rs b/pbs-config/src/user.rs index 8e10a778..f5ea03db 100644 --- a/pbs-config/src/user.rs +++ b/pbs-config/src/user.rs @@ -57,7 +57,7 @@ pub fn config() -> Result<(SectionConfigData, [u8; 32]), Error> { let digest = openssl::sha::sha256(content.as_bytes()); let mut data = CONFIG.parse(USER_CFG_FILENAME, &content)?; - if data.sections.get("root@pam").is_none() { + if !data.sections.contains_key("root@pam") { let user: User = User { userid: Userid::root_userid().clone(), comment: Some("Superuser".to_string()), diff --git a/src/api2/access/acl.rs b/src/api2/access/acl.rs index 1ec4bd3d..6fde99fd 100644 --- a/src/api2/access/acl.rs +++ b/src/api2/access/acl.rs @@ -233,7 +233,7 @@ pub fn update_acl( if !delete { // Note: we allow to delete non-existent users let user_cfg = pbs_config::user::cached_config()?; - if user_cfg.sections.get(&auth_id.to_string()).is_none() { + if !user_cfg.sections.contains_key(&auth_id.to_string()) { bail!(format!( "no such {}.", if auth_id.is_token() { diff --git a/src/api2/tape/drive.rs b/src/api2/tape/drive.rs index c6fc9f9c..ca76c6bf 100644 --- a/src/api2/tape/drive.rs +++ b/src/api2/tape/drive.rs @@ -495,7 +495,7 @@ pub fn label_media( if let Some(ref pool) = pool { let (pool_config, _digest) = pbs_config::media_pool::config()?; - if pool_config.sections.get(pool).is_none() { + if !pool_config.sections.contains_key(pool) { bail!("no such pool ('{}')", pool); } } @@ -1056,7 +1056,7 @@ pub fn barcode_label_media( if let Some(ref pool) = pool { let (pool_config, _digest) = pbs_config::media_pool::config()?; - if pool_config.sections.get(pool).is_none() { + if !pool_config.sections.contains_key(pool) { bail!("no such pool ('{}')", pool); } } diff --git a/src/config/acme/plugin.rs b/src/config/acme/plugin.rs index d3b2189d..ff66dec3 100644 --- a/src/config/acme/plugin.rs +++ b/src/config/acme/plugin.rs @@ -147,7 +147,7 @@ pub fn config() -> Result<(PluginData, [u8; 32]), Error> { let digest = openssl::sha::sha256(content.as_bytes()); let mut data = CONFIG.parse(ACME_PLUGIN_CFG_FILENAME, &content)?; - if data.sections.get("standalone").is_none() { + if !data.sections.contains_key("standalone") { let standalone = StandalonePlugin::default(); data.set_data("standalone", "standalone", &standalone) .unwrap(); -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel