3 ms·
I understood them to be saying that they would prefer (0..10).iter().for_each(|x| println!("{x}")) over the thing that I wrote. Many folks do not think of
by steveklabnik 2y ago
I understood them to be saying that they would prefer
(0..10).iter().for_each(|x| println!("{x}"))
over the thing that I wrote.
Many folks do not think of Rust's for loops as using iterators under the hood, and so will often talk about them as though they don't use iterators, even though they technically do.
- miguelraz 2y agoAuthor here, long time no see Steve! When I wrote this, my main takeaways were numerical computations with arrays, which don't tend to use for loops in Rust, and which require grokking iterators for maximum performance and rayon-parallelism boons. To a Julia audience, seeing this style of iterator chaining is quite a new flavor to think about composing computation, so I wanted it was with that audience in mind that I wrote this.
- steveklabnik 2y agoHey hey! Yeah I think that makes sense! I don't do that kind of work and so it's more usual in the kinds of code I write.