Relax Fn trait bounds in Command & Action#1409
Conversation
Could you elaborate a bit? Maybe provide some examples? |
The main issue is that I can only use pub async fn my_async_operation() -> Result<String> { /* -- snip -- */ }
// -- snip --
let config: Config = /* a temporary value in this scope */;
Command::perform(my_async_operation(), move |r| Message::OperationFinished(config, r))However, Rust will complain my closure doesn's impl |
... and revert `FnMut` usage.
|
I don't see a good use case for |
Thanks! That do help a lot. I changed |
In my practical use, I found that many methods in
CommandandActionrequires a strictFntrait bound (and even more like'staticandClone), which troubled me a lot. I think in some case such strict restrictions is no need.In this PR, I tried my best to relax these restrictions. At least for me, it was very helpful. Hope it can help more friends working around async.
BTW, I notice that the different types of
Actionand whetherCommandcontains only oneActioncan affect the minimal restriction. Maybe we can introduce more methods such asmap_single,map_future, etc. to make it more easy while mappingCommandandAction.