Crate of the Week

Higher-Rank Trait Bounds (HRTBs) are tricky to use with generic async functions:

where 
     F: for<'a> Fn(&'a …) -> Fut, 
     Fut: Future<Output = 'a …> // can't use the lifetime here!

The async_fn_traits crate contains a workaround in the form of async function traits:

where F: for<'a> AsyncFn1<&'a …, Output = 'a …> // works!
3 Likes