Closed
Description
Given the following code: (playground):
fn take_mut(_val: impl FnMut()) {}
fn main() {
let val = String::new();
take_mut(|| {
let _foo: String = val;
})
}
The current output is:
error[E0507]: cannot move out of `val`, a captured variable in an `FnMut` closure
--> src/main.rs:6:28
|
4 | let val = String::new();
| --- captured outer variable
5 | take_mut(|| {
6 | let _foo: String = val;
| ^^^
| |
| move occurs because `val` has type `String`, which does not implement the `Copy` trait
| help: consider borrowing here: `&val`
However, we do not point to the closure, or explain why it implements FnMut
. In a larger function, this can be confusing.