Features:
AsyncIterator
(the trait formerly known as Stream
)for await x in foo {}
These three features are independent of each other and can be advanced on their own. All three are needed to consider "async iteration" a "solved problem".
trait AsyncIterator
rustc
๐คsize_hint
for async iteration item ๐คAble to write custom sync and async iterators and combinators without creating a new struct
and impl
, and reducing the need to understand Pin
.
async generator zip<A, B>(
mut a: impl AsyncIterator<Item = A>,
mut b: impl AsyncIterator<Item = B>,
) yields (A, B) {
while let (Some(a), Some(b)) = (a.next().await, b.next().await) {
yield (a, b);
}
}
Having a single AsyncIterator
trait in std::
that can be used by the entire async ecosystem.
Allowing easy consumption of AsyncIterator
s by providing a new expression syntax for these.
async fn foo<I: Display>(x: impl AsyncIterator<Item = I> {
for await i in x {
println!("{}", i);
}
}
Potentially, enable syntactic sugar for "rayon-like" parallel iteration.
async fn foo<I: Display>(x: impl AsyncIterator<Item = I> {
for await (i, j, k) in x.chunks(3) {
println!("{} {} {}", i, j, k);
}
}
Not started.