From 18012d9ee897cd5da16927f54c15cdc0717b1bba Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 7 May 2021 10:15:08 +0000 Subject: [PATCH] virtio-devices: iommu: Address clippy issue error: usage of `contains_key` followed by `insert` on a `BTreeMap` --> virtio-devices/src/iommu.rs:439:17 | 439 | / if !mappings.contains_key(&domain) { 440 | | mappings.insert(domain, BTreeMap::new()); 441 | | } | |_________________^ help: try this: `mappings.entry(domain).or_insert_with(|| BTreeMap::new());` | = note: `-D clippy::map-entry` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_entry Signed-off-by: Rob Bradford --- virtio-devices/src/iommu.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/virtio-devices/src/iommu.rs b/virtio-devices/src/iommu.rs index 5afc30b8f..815f22d5f 100644 --- a/virtio-devices/src/iommu.rs +++ b/virtio-devices/src/iommu.rs @@ -436,9 +436,7 @@ impl Request { // Add new domain with no mapping if the entry didn't exist yet let mut mappings = mapping.mappings.write().unwrap(); - if !mappings.contains_key(&domain) { - mappings.insert(domain, BTreeMap::new()); - } + mappings.entry(domain).or_insert_with(BTreeMap::new); 0 }