From f2f81791d1adfd0a12343a738bf6f46b9edf5a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 20 Jan 2021 10:42:57 +0100 Subject: [PATCH] clippy: fix for_kv_map MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/config/acl.rs | 1 + src/server/report.rs | 2 +- src/tape/inventory.rs | 25 ++++++++++++------------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/config/acl.rs b/src/config/acl.rs index 63fd065e..6ef54e30 100644 --- a/src/config/acl.rs +++ b/src/config/acl.rs @@ -372,6 +372,7 @@ impl AclTreeNode { fn extract_group_roles(&self, _user: &Userid, leaf: bool) -> HashMap { 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 { diff --git a/src/server/report.rs b/src/server/report.rs index 848aa326..1b77f442 100644 --- a/src/server/report.rs +++ b/src/server/report.rs @@ -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(", ") diff --git a/src/tape/inventory.rs b/src/tape/inventory.rs index 446d9379..26d72528 100644 --- a/src/tape/inventory.rs +++ b/src/tape/inventory.rs @@ -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 { 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 { 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 { - 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 {