clippy: Address the issue 'needless-collect'

error: avoid using `collect()` when not needed
   --> vmm/src/vm.rs:630:86
    |
630 |             let node_id_list: Vec<u32> = configs.iter().map(|cfg| cfg.guest_numa_id).collect();
    |                                                                                      ^^^^^^^
...
664 |                         if !node_id_list.contains(&dest) {
    |                             ---------------------------- the iterator could be used here instead
    |
    = note: `-D clippy::needless-collect` implied by `-D warnings`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_collect

Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
Bo Chen 2021-06-23 15:05:38 -07:00 committed by Sebastien Boeuf
parent 5825ab2dd4
commit c4be0f4235

View File

@ -624,8 +624,6 @@ impl Vm {
let mut numa_nodes = BTreeMap::new(); let mut numa_nodes = BTreeMap::new();
if let Some(configs) = &configs { if let Some(configs) = &configs {
let node_id_list: Vec<u32> = configs.iter().map(|cfg| cfg.guest_numa_id).collect();
for config in configs.iter() { for config in configs.iter() {
if numa_nodes.contains_key(&config.guest_numa_id) { if numa_nodes.contains_key(&config.guest_numa_id) {
error!("Can't define twice the same NUMA node"); error!("Can't define twice the same NUMA node");
@ -658,7 +656,7 @@ impl Vm {
let dest = distance.destination; let dest = distance.destination;
let dist = distance.distance; let dist = distance.distance;
if !node_id_list.contains(&dest) { if !configs.iter().any(|cfg| cfg.guest_numa_id == dest) {
error!("Unknown destination NUMA node {}", dest); error!("Unknown destination NUMA node {}", dest);
return Err(Error::InvalidNumaConfig); return Err(Error::InvalidNumaConfig);
} }