I would like to implement an async function that takes async closure as the argument, so it must be called this way somewhere in the code:
my_func(async || { ... }).await;
What is the correct way to specify the data type of the argument?
I have tried this:
async fn my_func<F>(closure: F) where F: Fn() -> dyn std::future::Future<Output = ()> {
closure.await;
closure.await;
closure.await;
}
But I got the error:
expected trait object `dyn Future`, found `async` closure body