Try   HackMD

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"

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)