vmm: Fix clippy warnings for use of .clone()

warning: assigning the result of `Clone::clone()` may be inefficient
    --> vmm/src/device_manager.rs:4188:17
     |
4188 |                 id = child_id.clone();
     |                 ^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `id.clone_from(child_id)`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assigning_clones
     = note: `#[warn(clippy::assigning_clones)]` on by default

Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
This commit is contained in:
Rob Bradford 2024-03-19 16:36:05 +00:00 committed by Bo Chen
parent 2529ffd593
commit 521a0d1ade
2 changed files with 2 additions and 2 deletions

View File

@ -4185,7 +4185,7 @@ impl DeviceManager {
if !pci_device_node.children.is_empty() {
assert_eq!(pci_device_node.children.len(), 1);
let child_id = &pci_device_node.children[0];
id = child_id.clone();
id.clone_from(child_id);
}
}
for child in pci_device_node.children.iter() {

View File

@ -175,7 +175,7 @@ mod tests {
// Check get_mut()
let node = device_tree.get_mut(&id).unwrap();
node.id = id2.clone();
node.id.clone_from(&id2);
let node = device_tree.0.get(&id).unwrap();
assert_eq!(node.id, id2);