I often find that I am writing code like:
myvec.iter().map(|x| some_operation(x)).count()
The call countstarts a chain of iterators that will be consumed, but also produces, if not a single result, which is undesirable.
I'm looking for something like
myvec.iter().map(|x| some_operation(x)).consume()
which should be equivalent
for _ in myvec.iter().map(|x| some_operation(x)) {}
source
share