Closed
Description
use std::thread;
fn main() {
let things = vec![1,2,3,4];
let mut buf = vec![];
let handle_thread: Vec<_> = things.iter().map(|&d| {
thread::spawn(move || {
do_thing(&mut buf);
})
}).collect();
}
fn do_thing(x: &mut [u8]) {}
(https://gist.github.com/772bde36b6cddebcd46a)
gives
<anon>:11:17: 13:4 error: cannot move out of captured outer variable in an `FnMut` closure [E0507]
<anon>:11 thread::spawn(move || {
<anon>:12 do_thing(&mut buf);
<anon>:13 })
error: aborting due to previous error
Except that it's totally confusing as to which outer variable is being talked about. In this case it's obvious since there's a single capture, but this won't always be the case.
The error should at least mention the name of the captured variable, and preferably point out where the variable was captured and how to fix it.