Ok, I'm confused about iterators in an async context in #Rust.

Iterators provide results over next; each time the caller uses .next(), the iterator returns the element (or None if there are no more elements).

But in an async context, how would .next() do some async call if the function itself is not async? The first thing that comes to mind is that I need to block_on the call, but that would, in Tokio, require a runtime, and I can't find a way to get the current runtime...

Or am I with the wrong mental model?

@juliobiason Iterators aren't async, and next() has no choice but block.

You might have an iterator returning Futures, but that's just passing objects through a sync iterator anyway.

There's Stream type (in the futures crate) for proper async iteration, which has async-supporting equivalents.