Announcing `async fn` and return-position `impl Trait` in traits (Rust Blog)
Ever since the stabilization of RFC #1522 in Rust 1.26, Rust has allowed users to write impl Trait as the return type of functions (often called "RPIT"). This means that the function returns "some type that implements Trait". This is commonly used to return closures, iterators, and other types that are complex or impossible to write explicitly. [...]Starting in Rust 1.75, you can use return-position impl Trait in trait (RPITIT) definitions and in trait impls. For example, you could use this to write a trait method that returns an iterator: [...]
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 in traits, we also permit you to write traits that use async fn.
Posted Dec 21, 2023 16:27 UTC (Thu)
by simon.d (guest, #168021)
[Link]
Announcing `async fn` and return-position `impl Trait` in traits (Rust Blog)
Thanks to everyone making this possible!