4 ms·
I think that's bit too pedantic. Most people in the Rust community refer to for expressions as for loops (including the book). It's especially odd to point out
by dist1ll 2y ago
I think that's bit too pedantic. Most people in the Rust community refer to for expressions as for loops (including the book).
It's especially odd to point out this language detail, because for expressions always return the unit type. So it's not like you can do something with the return value (unlike loop expression, which can evaluate to one of its break expressions).
- John23832 2y agoThe ergonomics of c style for loops and iterator style loops are totally different. It’s the reason for crates like itertools. I don’t think that is pedantic at all.
- dist1ll 2y agoSure, but that's kind of beside the point I was making. The author was contrasting loops - an imperative construct (which both C-style for and iterator-based for are examples of) - to the functional style of chaining iterator functions, adapters & reductions and passing closures around. FWIW I agree with you, it's just that I was trying to make a distinction between imperative and functional style in Rust (just like the author was trying to do) - not literally claiming Rust has C-style for loops.