wg-async icon indicating copy to clipboard operation
wg-async copied to clipboard

Plan: async Iterator

Open tmandry opened this issue 1 year ago • 2 comments

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 avatar Mar 07 '23 01:03 tmandry

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.

tmandry avatar Apr 28 '23 17:04 tmandry

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".

yoshuawuyts avatar Oct 05 '23 16:10 yoshuawuyts