DEV Community

Discussion on: Converting bits to integers in Rust using generics

Collapse
 
khodzha profile image
Shamir Khodzha

you can replace filter().count() > 0 with any() (or all() and reversed predicate) and it will shortcircuit: exit as soon as you find first non 0 and non 1, thus making this whole walk through vector faster

Collapse
 
citizen_stig profile image
Nikolai Golub

Thanks Shamir, it is a good improvement!