How do I cope with lazy iterators?

As the book you linked to says:

If you are trying to execute a closure on an iterator for its side effects, use for instead.

That way it works, and it’s much clearer to anyone reading the code. You should use map when you want to transform a vector to a different one.

Leave a Comment