Passing a closure that modifies its environment to a function in Rust
问题 I have a closure that captures and modifies its environment. I want to pass this closure to a function that accepts closures: fn main() { let mut integer = 5; let mut closure_variable = || -> i32 { integer += 1; integer }; execute_closure(&mut closure_variable); } fn execute_closure(closure_argument: &mut Fn() -> i32) { let result = closure_argument(); println!("Result of closure: {}", result); } Because the closure modifies its environment, this fails: error[E0525]: expected a closure that