We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 425a70a commit c07e558Copy full SHA for c07e558
library/core/src/str/iter.rs
@@ -47,11 +47,7 @@ impl<'a> Iterator for Chars<'a> {
47
#[inline]
48
fn count(self) -> usize {
49
// 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
+ self.iter.map(|&byte| !utf8_is_cont_byte(byte) as usize).sum()
55
}
56
57
0 commit comments