]> git.proxmox.com Git - proxmox-backup.git/commitdiff
clippy: fix for_kv_map
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 20 Jan 2021 09:42:57 +0000 (10:42 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 20 Jan 2021 15:23:54 +0000 (16:23 +0100)
and allow it in the one case where the entry loop is intended, but the
code is not yet implemented fully.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/config/acl.rs
src/server/report.rs
src/tape/inventory.rs

index 63fd065e5f0393a38f42d58b9c846491ce24626e..6ef54e30f778d80268763fdc1c0ed23c98f60640 100644 (file)
@@ -372,6 +372,7 @@ impl AclTreeNode {
     fn extract_group_roles(&self, _user: &Userid, leaf: bool) -> HashMap<String, bool> {
         let mut map = HashMap::new();
 
+        #[allow(clippy::for_kv_map)]
         for (_group, roles) in &self.groups {
             let is_member = false; // fixme: check if user is member of the group
             if !is_member {
index 848aa326be180083b62ae75006ba6209db4cd8da..1b77f442803ee2e5a3e5a9e9a9f0837fe843a6fc 100644 (file)
@@ -39,7 +39,7 @@ fn function_calls() -> Vec<(&'static str, fn() -> String)> {
             };
 
             let mut list = Vec::new();
-            for (store, _) in &config.sections {
+            for store in config.sections.keys() {
                 list.push(store.as_str());
             }
             list.join(", ")
index 446d937932a9cd2335486f6c2a19b98cc4e69586..26d72528e7bbd2fc86dbf7d3533e614d21ef543e 100644 (file)
@@ -215,12 +215,13 @@ impl Inventory {
 
     /// find media by label_text
     pub fn find_media_by_label_text(&self, label_text: &str) -> Option<&MediaId> {
-        for (_uuid, entry) in &self.map {
+        self.map.values().find_map(|entry| {
             if entry.id.label.label_text == label_text {
-                return Some(&entry.id);
+                Some(&entry.id)
+            } else {
+                None
             }
-        }
-        None
+        })
     }
 
     /// Lookup media pool
@@ -245,7 +246,7 @@ impl Inventory {
     pub fn list_pool_media(&self, pool: &str) -> Vec<MediaId> {
         let mut list = Vec::new();
 
-        for (_uuid, entry) in &self.map {
+        for entry in self.map.values() {
             match entry.id.media_set_label {
                 None => continue, // not assigned to any pool
                 Some(ref set) => {
@@ -272,7 +273,7 @@ impl Inventory {
     pub fn list_used_media(&self) -> Vec<MediaId> {
         let mut list = Vec::new();
 
-        for (_uuid, entry) in &self.map {
+        for entry in self.map.values() {
             match entry.id.media_set_label {
                 None => continue, // not assigned to any pool
                 Some(ref set) => {
@@ -288,15 +289,13 @@ impl Inventory {
 
     /// List media not assigned to any pool
     pub fn list_unassigned_media(&self) -> Vec<MediaId> {
-        let mut list = Vec::new();
-
-        for (_uuid, entry) in &self.map {
+        self.map.values().filter_map(|entry|
             if entry.id.media_set_label.is_none() {
-                list.push(entry.id.clone());
+                Some(entry.id.clone())
+            } else {
+                None
             }
-        }
-
-        list
+        ).collect()
     }
 
     pub fn media_set_start_time(&self, media_set_uuid: &Uuid) -> Option<i64> {