Announcing `async fn` and return-position `impl Trait` in traits (Rust Blog)
The Rust Blog announcesthe stabilization of a couple of trait features aimed at improving supportfor async code:
Ever since the stabilization of RFC #1522 in Rust 1.26, Rust hasallowed users to write impl Trait as the return type offunctions (often called "RPIT"). This means that the functionreturns "some type that implements Trait". This iscommonly used to return closures, iterators, and other types thatare complex or impossible to write explicitly. [...]Starting in Rust 1.75, you can use return-position implTrait in trait (RPITIT) definitions and in trait impls. Forexample, you could use this to write a trait method that returns aniterator: [...]
So what does all of this have to do with async functions? Well,async functions are "just sugar" for functions that return-> impl Future. Since these are now permitted intraits, we also permit you to write traits that use async fn.