Async: Constrain lifetime of Fut type param to lifetime of for<'func>F: Fn(..) -> Fut

Box::pin is the easiest way to do it. Otherwise, it won't be ergonomic. Also see How to express that the Future returned by a closure lives only as long as its argument?


BTW, I've added the code here as an example of showing how it can be acheived with my crate async_closure:

1 Like