]> git.proxmox.com Git - proxmox-backup.git/commitdiff
replace get(key).is_none() with !contains_key()
authorMaximiliano Sandoval <m.sandoval@proxmox.com>
Wed, 26 Jun 2024 13:05:59 +0000 (15:05 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 28 Jun 2024 07:20:59 +0000 (09:20 +0200)
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 <m.sandoval@proxmox.com>
pbs-config/src/acl.rs
pbs-config/src/network/parser.rs
pbs-config/src/user.rs
src/api2/access/acl.rs
src/api2/tape/drive.rs
src/config/acme/plugin.rs

index 8a1423cca1f171b59d11777c3e374ffce785db96..8b6215ef20cfb6ffbb255259fb5fbccb103fb86e 100644 (file)
@@ -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));
             }
         }
 
index 2158a04fc45d22da36ea9c4ee96e72559e8c6b25..7498dd3528cef1798dffffcf36ff538d823f8b47 100644 (file)
@@ -585,7 +585,7 @@ impl<R: BufRead> NetworkParser<R> {
             }
         }
 
-        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;
index 8e10a778dfb9f6ff79acce2766963d69ff916d27..f5ea03db31f7c931ac34368b57b5258f84fe94fa 100644 (file)
@@ -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()),
index 1ec4bd3d41a7c39aede1b0a2185b970c06e013f9..6fde99fd332fe9f6f49c693e5066ba5069f1e867 100644 (file)
@@ -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() {
index c6fc9f9c27ea075633677711c3f6001ae8487c06..ca76c6bfa3a0713a03b0f282595b1f6571d28ace 100644 (file)
@@ -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);
         }
     }
index d3b2189d3e43b5b9dadae9ca60f2be0d3cf6b8ad..ff66dec3908165a4976c8b29c2906dbf936ff1b7 100644 (file)
@@ -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();