I'm trying to send a closure into a thread to process like:
fn spawn<F>(work_load: F) where F: FnMut() {
let builder = Builder::new();
let handler = builder.spawn(move || {
// Before process
work_load();
// After process
}).unwrap();
}
But I'm getting an error:
F cannot be sent between threads safely
In a high overview I need to do this (code compiles):
let closure = || env_variable.to_string();
thread::spawn(move || {
// before closure
closure();
// after closure
});
How I can define F so I can send it into thread, considering I need to capture environment.