If I add let ss = s
between those two f()
, the compiler will complain:
2 | let s = String::from("test");
| - move occurs because `s` has type `String`, which does not implement the `Copy` trait
3 |
4 | let f = move || {
| ------- value moved into closure here
5 | println!("{}", s);
| - variable moved due to use in closure
...
9 | let ss = s;
| ^ value used here after move