I'm studying concurrency now. I wrote the below code to understand it, but an error occurs about lifetime. I do not understand this error. https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=192bf1e138febc37ed1f3772a18f16d4
use std::thread;
fn main() {
let mut handles = Vec::new();
for x in 0..10 {
handles.push(thread::spawn(|| {
println!("{}", x);
}));
}
for handle in handles {
handle.join();
}
}
An error message is
closure may outlive the current function, but it borrows `x`, which is owned by the current function
In this message, what function "the current function" means? If this means fn main(), closure must be in it, so I cannot understand this error message.