Open tezlm opened 8 months ago
This can be worked around by writing the higher-rank trait bound for the function type, rather than relying on lifetime elision.
#[async_trait::async_trait]
trait Bar {
async fn foo(&self, call: &(dyn (for<'a> Fn(&'a String) -> bool) + Sync));
^^^^^^^ ^^
}
#[async_trait::async_trait]
impl Bar for Foo {
async fn foo(&self, call: &(dyn (for<'a> Fn(&'a String) -> bool) + Sync)) {
^^^^^^^ ^^
let thing = "a".to_string();
call(&thing);
}
}
On latest
async-trait
(0.1.77) this code doesn't compile:This expands to:
And gives the compiler error:
Manually removing
'life2
makes the code compile.