Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 607 Bytes

File metadata and controls

25 lines (18 loc) · 607 Bytes

Simple names

One simple way to give names to async functions is to just generate a name based on the method. For example:

trait AsyncIterator {
    type Item;
    async fn next(&mut self) -> Self::Item;
}

could desugar to

trait AsyncIterator {
    type Item;
    type Next<'me>: Future<Output = Self::Item> + 'me;
    fn next(&mut self) -> Self::Next<'_>;
}

Users could then name the future with <T as AsyncIterator>::Next<'a>.

This is a simple solution, but not a very general one, and perhaps a bit surprising (for example, there is no explicit declaration of Next).