How can I pass a reference to Arc<A>
so that the following code compiles successfully?
use std::sync::Arc;
trait A {
fn send(&self);
}
struct B;
impl A for B {
fn send(&self) {
println!("SENT");
}
}
fn ss(a: &Arc<A>) {
let aa = a.clone();
aa.send();
}
fn main() {
let a = Arc::new(B);
ss(&a);
}
If I omit the reference, it compiles okay, but Clippy warns me that in such situation in makes no sense.
Clippy error on the code without reference:
Compiling playground v0.0.1 (file:///playground)
warning: this argument is passed by value, but not consumed in the function body
--> src/main.rs:13:10
|
13 | fn ss(a: Arc<A>) {
| ^^^^^^ help: consider taking a reference instead: `&Arc<A>`
|
= note: #[warn(needless_pass_by_value)] on by default
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.186/index.html#needless_pass_by_value