From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ronja.mits.lan by ronja.mits.lan with LMTP id 0A23C1/xe2a1SAAAxxbTJA (envelope-from ); Wed, 26 Jun 2024 12:45:51 +0200 Received: from proxmox-new.maurer-it.com (unknown [192.168.2.33]) by ronja.mits.lan (Postfix) with ESMTPS id 1BA41F64634; Wed, 26 Jun 2024 12:45:51 +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 02A61486E2; Wed, 26 Jun 2024 12:45:51 +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 12:45:50 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CA0421E222; Wed, 26 Jun 2024 12:45:49 +0200 (CEST) From: Maximiliano Sandoval To: pbs-devel@lists.proxmox.com Date: Wed, 26 Jun 2024 12:44:58 +0200 Message-Id: <20240626104514.384718-2-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626104514.384718-1-m.sandoval@proxmox.com> References: <20240626104514.384718-1-m.sandoval@proxmox.com> MIME-Version: 1.0 Subject: [pbs-devel] [PATCH proxmox 02/18] use contains_key instead of .get().is_{some, none}() 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 lints: warning: unnecessary use of `get("lo").is_none()` --> proxmox-network-api/src/config/parser.rs:603:30 | 603 | if config.interfaces.get("lo").is_none() { | ------------------^^^^^^^^^^^^^^^^^^^ | | | help: replace it with: `!config.interfaces.contains_key("lo")` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check = note: `#[warn(clippy::unnecessary_get_then_check)]` on by default Signed-off-by: Maximiliano Sandoval --- proxmox-access-control/src/acl.rs | 6 +++--- proxmox-acme-api/src/plugin_config.rs | 2 +- proxmox-network-api/src/config/parser.rs | 2 +- proxmox-section-config/src/lib.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/proxmox-access-control/src/acl.rs b/proxmox-access-control/src/acl.rs index b6b7b400..af68159c 100644 --- a/proxmox-access-control/src/acl.rs +++ b/proxmox-access-control/src/acl.rs @@ -973,14 +973,14 @@ mod test { 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 { let node = tree.find_node(path); assert!(node.is_some()); if let Some(node) = node { - assert!(node.users.get(&user2).is_some()); + assert!(node.users.contains_key(&user2)); } } @@ -990,7 +990,7 @@ mod test { 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/proxmox-acme-api/src/plugin_config.rs b/proxmox-acme-api/src/plugin_config.rs index 4ebd0315..e0836f50 100644 --- a/proxmox-acme-api/src/plugin_config.rs +++ b/proxmox-acme-api/src/plugin_config.rs @@ -67,7 +67,7 @@ pub(crate) fn plugin_config() -> Result<(PluginData, ConfigDigest), Error> { let digest = ConfigDigest::from_slice(content.as_bytes()); let mut data = CONFIG.parse(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(); diff --git a/proxmox-network-api/src/config/parser.rs b/proxmox-network-api/src/config/parser.rs index dc8e2d0a..2d20b9e4 100644 --- a/proxmox-network-api/src/config/parser.rs +++ b/proxmox-network-api/src/config/parser.rs @@ -600,7 +600,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/proxmox-section-config/src/lib.rs b/proxmox-section-config/src/lib.rs index 526ee8f1..e36d8995 100644 --- a/proxmox-section-config/src/lib.rs +++ b/proxmox-section-config/src/lib.rs @@ -322,7 +322,7 @@ impl SectionConfig { let mut done = HashSet::new(); for section_id in &config.order { - if config.sections.get(section_id).is_none() { + if !config.sections.contains_key(section_id) { continue; }; list.push(section_id); -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel