I want to have a function that takes a function pointer of async fn
.
What should the type of f
be in fn run
?
async fn foo() {}
fn run(f: /* ??? */) {}
According to the async/await RFC:
An
async fn foo(args..) -> T
is a function of the typefn(args..) -> impl Future<Output = T>
.
However, if I write
fn run(f: fn() -> impl Future<()>)
I get the error message:
`impl Trait` not allowed outside of function and inherent method return types