# Status of async fn in traits A brief overview. What we call "async fn in traits" is really multiple parts: * Core support: ability to write `async fn` in traits + impls * Bounding: ability to say `T: AsyncIter` but also "the future returned by `next()` is `Send`" * Dynamic dispatch: ability to use `dyn AsyncIter` and invoke `async fn` methods * RPITIT: sometimes you want an async fn that doesn't capture everything. This would most naturally be expressed with `-> impl Future` in the trait, though GATs + TAITs work too. And some auxiliary/optonal parts: * Refinements: ability to write `async fn` in trait but `-> impl Future` in impl, or other more specific future types, in impl Current status: | Part | Status | | --- | --- | | Core support | feature complete, but fixing bugs and writing tests | | Bounding | have a proposal to address this that needs to be better circulated, ["return type notation"] | | Dynamic dispatch | design space is enumerated, need to settle on a concrete design | | RPITIT | feature complete, but needs cleanup and also authoring of tests; GATs + TAITs will allow this to be written in "desugared form"| ["return type notation"]: https://hackmd.io/9AH8Zr9ESMmur0n6Nix96w?view#Bounding-with-Send-Sync-and-other-bounds Dynamic dispatch is a complex topic, but there are two main designs, and they come with their own dependencies: | Design | Dependencies | | --- | --- | | Decide alloc strategy at call site ([part 9]) | returning of unsized values | | Decide when creating dyn what adapter to use ([part 8]) | [`dyn*`] (started, needs elaboration) | [part 9]: https://smallcultfollowing.com/babysteps/blog/2022/09/21/dyn-async-traits-part-9-callee-site-selection/ [part 8]: http://smallcultfollowing.com/babysteps/blog/2022/09/18/dyn-async-traits-part-8-the-soul-of-rust/ [`dyn*`]: http://smallcultfollowing.com/babysteps/blog/2022/03/29/dyn-can-we-make-dyn-sized/