Open
Description
What it does
Lints against uses of move
before a closure or async
block that captures nothing by reference.
Advantage
This is likely the result of a mistake from the implementer, which does not have the proper intuition about how closure borrow their contents. Sometimes it can be hard to reason about it.
For example the developer might not realise that a capture that is passed by value is always captured by value.
Drawbacks
No response
Example
let a = String::new();
let closure = move || {
drop(a);
};
Could be written as:
let a = String::new();
let closure = || {
drop(a);
};
Because the String is always captured by value, since it needs to be passed by value to drop
.