Arc<Mutex<dyn FnOnce(A) -> A>> for closure in Rust
Solution 1:
The Foo
is expecting a Arc<Mutex<dyn FnOnce>>
, so if you pass just a closure you'll get that error. You can get around that by constructing the Arc and Mutex:
let foo = Foo {
mut_f: Arc::new(Mutex::new(identity))
};