This is my latest attempt to pass around a closure through multiple nested structs.
Compiling playground v0.0.1 (file:///playground)
error[E0277]: the trait bound `[closure@src/main.rs:71:27: 71:100]: ActionClosure` is not satisfied
--> src/main.rs:72:15
|
72 | let ctx = Context::new(action, 7);
| ^^^^^^^^^^^^ the trait `ActionClosure` is not implemented for `[closure@src/main.rs:71:27: 71:100]`
|
= note: required by `<Context<A>>::new`
error[E0277]: the trait bound `[closure@src/main.rs:71:27: 71:100]: ActionClosure` is not satisfied
--> src/main.rs:72:15
|
72 | let ctx = Context::new(action, 7);
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `ActionClosure` is not implemented for `[closure@src/main.rs:71:27: 71:100]`
|
= note: required by `Context`
error[E0599]: no method named `handle` found for type `Context<[closure@src/main.rs:71:27: 71:100]>` in the current scope
--> src/main.rs:74:9
|
74 | ctx.handle();
| ^^^^^^
|
= note: the method `handle` exists but the following trait bounds were not satisfied:
`[closure@src/main.rs:71:27: 71:100] : ActionClosure`
error[E0277]: the trait bound `[closure@src/main.rs:71:27: 71:100]: ActionClosure` is not satisfied
--> src/main.rs:76:5
|
76 | println!("{:?}", ctx);
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `ActionClosure` is not implemented for `[closure@src/main.rs:71:27: 71:100]`
|
= note: required by `Context`
= note: this error originates in a macro outside of the current crate
error[E0277]: the trait bound `[closure@src/main.rs:71:27: 71:100]: ActionClosure` is not satisfied
--> src/main.rs:76:22
|
76 | println!("{:?}", ctx);
| ^^^ the trait `ActionClosure` is not implemented for `[closure@src/main.rs:71:27: 71:100]`
|
= note: required because of the requirements on the impl of `std::fmt::Debug` for `Context<[closure@src/main.rs:71:27: 71:100]>`
= note: required by `std::fmt::Debug::fmt`
error: aborting due to 5 previous errors
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
But I am not sure how to deal with this. I read a couple of blogs, and the boxed function seems to be the way to go, but I am still not sure how to cover my use case best.