3 ms·
The Rust docs for the 'for' keyword do say for loops are implemented as sugar for iterator loops. https://doc.rust-lang.org/std/keyword.for.html https://doc.rus
by dwattttt 4y ago
The Rust docs for the 'for' keyword do say for loops are implemented as sugar for iterator loops.
https://doc.rust-lang.org/std/keyword.for.html https://doc.rust-lang.org/std/keyword.for.html
Relevant part:
> for-in-loops, or to be more precise, iterator loops, are a simple syntactic sugar over a common practice within Rust, which is to loop over anything that implements IntoIterator until the iterator returned by .into_iter() returns None (or the loop body uses break).
(The other uses of the 'for' keyword it refers to are unrelated to loops)