From 5e55be4b7ac58094fa0e22131f9daa25568960c5 Mon Sep 17 00:00:00 2001 From: Salvatore Testa Date: Thu, 1 Feb 2024 14:32:30 -0800 Subject: [PATCH] Make Target copy-able MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clippy also informed us that we can drop some of the clone calls. ``` ❯ cargo clippy Checking veilid-core v0.2.5 (~/Developer/veilid/veilid-core) error: using `clone` on type `Target` which implements the `Copy` trait --> veilid-core/src/storage_manager/record_store.rs:912:33 | 912 | target: w.target.clone(), | ^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `w.target` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy note: the lint level is defined here --> veilid-core/src/lib.rs:25:9 | 25 | #![deny(clippy::all)] | ^^^^^^^^^^^ = note: `#[deny(clippy::clone_on_copy)]` implied by `#[deny(clippy::all)]` error: using `clone` on type `Target` which implements the `Copy` trait --> veilid-core/src/storage_manager/watch_value.rs:199:21 | 199 | target.clone(), | ^^^^^^^^^^^^^^ help: try removing the `clone` call: `target` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy error: using `clone` on type `Target` which implements the `Copy` trait --> veilid-core/src/storage_manager/mod.rs:737:17 | 737 | vc.target.clone(), | ^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `vc.target` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy error: could not compile `veilid-core` (lib) due to 3 previous errors ``` --- veilid-core/src/storage_manager/mod.rs | 2 +- veilid-core/src/storage_manager/record_store.rs | 2 +- veilid-core/src/storage_manager/watch_value.rs | 2 +- veilid-core/src/veilid_api/routing_context.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/veilid-core/src/storage_manager/mod.rs b/veilid-core/src/storage_manager/mod.rs index 45749c24..60ae420d 100644 --- a/veilid-core/src/storage_manager/mod.rs +++ b/veilid-core/src/storage_manager/mod.rs @@ -734,7 +734,7 @@ impl StorageManager { let dest = rpc_processor .resolve_target_to_destination( - vc.target.clone(), + vc.target, SafetySelection::Unsafe(Sequencing::NoPreference), ) .await diff --git a/veilid-core/src/storage_manager/record_store.rs b/veilid-core/src/storage_manager/record_store.rs index 256107c4..8d55c00b 100644 --- a/veilid-core/src/storage_manager/record_store.rs +++ b/veilid-core/src/storage_manager/record_store.rs @@ -909,7 +909,7 @@ where } evcis.push(EarlyValueChangedInfo { - target: w.target.clone(), + target: w.target, key: rtk.key, subkeys, count, diff --git a/veilid-core/src/storage_manager/watch_value.rs b/veilid-core/src/storage_manager/watch_value.rs index 097bbd1d..22344916 100644 --- a/veilid-core/src/storage_manager/watch_value.rs +++ b/veilid-core/src/storage_manager/watch_value.rs @@ -196,7 +196,7 @@ impl StorageManager { subkeys.clone(), expiration, count, - target.clone(), + target, watcher, ) .await?; diff --git a/veilid-core/src/veilid_api/routing_context.rs b/veilid-core/src/veilid_api/routing_context.rs index 59ca2a46..06931c5d 100644 --- a/veilid-core/src/veilid_api/routing_context.rs +++ b/veilid-core/src/veilid_api/routing_context.rs @@ -3,7 +3,7 @@ use super::*; /////////////////////////////////////////////////////////////////////////////////////// /// Valid destinations for a message sent over a routing context -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq, Hash, Copy, PartialOrd, Ord)] pub enum Target { /// Node by its public key NodeId(TypedKey),