Skip to content

Commit c07e558

Browse files
committed
Let's try the most idiomatic way.
1 parent 425a70a commit c07e558

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

library/core/src/str/iter.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ impl<'a> Iterator for Chars<'a> {
4747
#[inline]
4848
fn count(self) -> usize {
4949
// length in `char` is equal to the number of non-continuation bytes
50-
let mut char_count = 0;
51-
for &byte in self.iter {
52-
char_count += !utf8_is_cont_byte(byte) as usize;
53-
}
54-
char_count
50+
self.iter.map(|&byte| !utf8_is_cont_byte(byte) as usize).sum()
5551
}
5652

5753
#[inline]

0 commit comments

Comments
 (0)