[Discussion] Alternative syntax for async iteration: `for async i in stream`?
scottmcm:
FWIW, other languages also uses
awaithere. For example,await foreachin C#: C# - Iterating with Async Enumerables in C# 8 | Microsoft Learn.
asyncis for "this is a thunk", but that's not what's happening in a for loop.
Fair point on C#, but Rust's design philosophy often excels when it diverges from other languages to favor its own strengths: patterns and bindings.
While await describes an imperative action, async in for async i describes the nature of the binding. In Rust, where we use patterns like for &x in ..., treating asynchrony as a property of the data flow (the binding i) feels more "Rust-y" and forward-looking than just adding an imperative await keyword because others did.
Let's prioritize semantic consistency with Rust's own async ecosystem over following the await foreach precedent.
Discussion in the ATmosphere