How do Rust closures work and how does it execute a closure?
问题 Does it create a new thread and then execute that anonymous function inside the new thread? I noticed many ownership / borrowing restrictions when I'm working with a closure. For example, if I have Fn() , I cannot pass a mutable variable inside the closure or it needs to be wrapped with a Mutex: fn helloworld(f: &Fn(f64)) { f(42f64); } pub fn main() { let mut killer = 2; helloworld(&|n| { println!("{}", n); killer += 1; }); } If a closure can be unsafe like that then something asynchronous or