rust iterator foreach code example
Example: rust for vs for_each
This is equivalent to using a for loop on the iterator,
although break and continue are not possible from a closure.
It's generally more idiomatic to use a for loop,
but for_each may be more legible when processing
items at the end of longer iterator chains.
In some cases for_each may also be faster than a loop,
because it will use internal iteration on adaptors like Chain.