Following code won't compile because I don't know what the fn
signature should be.
use std::future::Future;
pub trait Call {
fn call<'result, 'this: 'result>(&'this self) -> Box<dyn Future<Output = ()> + 'result> {
Box::new(async {})
}
}
struct A;
impl Call for A {}
fn main() {
let _: fn(&A) -> Box<dyn Future<Output = ()>> = A::call;
}
If I change the code like this it compiles with HRTB:
use std::future::Future;
pub trait Call {
fn call<'this>(&'this self) -> Box<dyn Future<Output = ()> + 'this> {
Box::new(async {})
}
}
struct A;
impl Call for A {}
fn main() {
let _: for<'this> fn(&'this A) -> Box<dyn Future<Output = ()> + 'this> = A::call;
}
However the upper one is generated by async_trait
so it's not easy to change the signature.