The Rust Programming Language Forum
Is there a shorthand for counting items in an iterator that satisfy a predicate?
help
bjorn3
December 19, 2020, 5:04pm
2
I think
input.iter().filter(predicate).count()
will work.
8 Likes
show post in topic
Related topics
Topic
Replies
Views
Activity
How to count multiple filters of same iterator?
help
11
375
August 16, 2024
Explain filter method
4
3979
December 31, 2021
Constrained Iterator Sum
4
110
June 12, 2025
.map(), .filter(), but no .each()
13
6257
January 12, 2023
Breaking out of a (fold) iterator?
code review
4
3053
August 3, 2021