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
381
August 16, 2024
Explain filter method
4
4154
December 31, 2021
Constrained Iterator Sum
4
113
June 12, 2025
.map(), .filter(), but no .each()
13
6287
January 12, 2023
Breaking out of a (fold) iterator?
code review
4
3069
August 3, 2021