Closed
Description
What it does
Catches the places where clone_from
could be used instead
Lint Name
clone_from_candidate
Category
pedantic
Advantage
From the docs
a.clone_from(&b)
is equivalent toa = b.clone()
in functionality, but can be overridden to reuse the resources of a to avoid unnecessary allocations.
Drawbacks
I can't think of any
Example
let mut a = "a".to_owned();
let b = "b".to_owned();
a = b.clone();
drop(b);
Could be written as:
let mut a = "a".to_owned();
let b = "b".to_owned();
a.clone_from(&b);
drop(b);