.clone()
in assignment RS-W1070.clone()
for assignment to variable197 }
198 InstructionKind::Name(name) => {
199 if in_macro && macro_name.is_empty() {
200 macro_name = name.clone();201 continue;
202 }
203 }
Consider using .clone_from()
instead of assigning the result of .clone()
.
clone_from()
may perform better in some cases because some structs may have custom implementations of clone_from()
, which improve performance by avoiding needless allocations.
fn foo(v: &mut Bar) {
let h = Bar::new();
// work with h
*v = h.clone();
}
fn foo(v: &mut Bar) {
let h = Bar::new();
// work with h
v.clone_from(&h);
}