Closed
Description
Clippy will suggest replacing
let x = mem::replace(&mut thing, Thing::default());
with:
let x = mem::take(&mut thing);
This is great! But it will also suggest replacing
mem::replace(&mut thing, Thing::default());
with:
mem::take(&mut thing);
This is not great. The construction using mem::replace
in the second case is much clearer IMO as it indicates that the function is being executed for its side effects. The construction using mem::take
looks like a mistake.
Would you folks be open to making the lint not apply in the second case?