rust-lang / wg-async

Working group dedicated to improving the foundations of Async I/O in Rust
https://rust-lang.github.io/wg-async/
Apache License 2.0
379 stars 88 forks source link

Plan: async Iterator #287

Open tmandry opened 1 year ago

tmandry commented 1 year ago

This is a roadmap item for wg-async. You can view the roadmap here: https://github.com/orgs/rust-lang/projects/28

Write a short doc on the kind of design we expect, and open questions, on this topic (#280).

tmandry commented 1 year ago

Update: Still need to write out how this doesn't block async fn in trait.

Main concerns are around cancel-safety and poll_next vs next, but these shouldn't interact with AFIT.

We also need some discussion of how to migrate to a LendingIterator (supertrait) or GAT-ify the existing Iterator trait. No known interactions with AFIT here.

yoshuawuyts commented 1 year ago

Main concerns are around cancel-safety and poll_next vs next, but these shouldn't interact with AFIT.

I've written an in-depth analysis of how both approaches compare here: https://blog.yoshuawuyts.com/async-iterator-trait. Basing our async traits on AFITs seems like it's clearly the superior direction.

While knowing that basing async iterator on AFITs works well, we also need a strategy for how to integrate it into the stdlib. For that reason we should probably this work on "effect-generic trait declarations". As well as consider not just adding the "async iterator" trait by itself, but re-RFC it to include a full story describing "async iteration".