From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ronja.mits.lan by ronja.mits.lan with LMTP id 4E37Oof4e2YUVgAAxxbTJA (envelope-from ); Wed, 26 Jun 2024 13:16:23 +0200 Received: from proxmox-new.maurer-it.com (unknown [192.168.2.33]) by ronja.mits.lan (Postfix) with ESMTPS id D3050F6462A; Wed, 26 Jun 2024 13:16:23 +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 B6F8148722; Wed, 26 Jun 2024 13:16:23 +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 13:16:22 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 254151E7E5; Wed, 26 Jun 2024 13:16:21 +0200 (CEST) Mime-Version: 1.0 Date: Wed, 26 Jun 2024 13:16:17 +0200 Message-Id: From: "Shannon Sterz" To: "Proxmox Backup Server development discussion" X-Mailer: aerc 0.17.0-69-g65571b67d7d3-dirty References: <20240626104514.384718-1-m.sandoval@proxmox.com> <20240626104514.384718-2-m.sandoval@proxmox.com> In-Reply-To: <20240626104514.384718-2-m.sandoval@proxmox.com> Subject: Re: [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 On Wed Jun 26, 2024 at 12:44 PM CEST, Maximiliano Sandoval wrote: > 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") { you missed a "!" here `contains_key` returns `true` when the key is there, `is_none` is true when it isn't. > 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); _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel