From a623ea5301737507a8229c2ddae74b20f727bd1b Mon Sep 17 00:00:00 2001 From: Giles Cope Date: Tue, 26 Jan 2021 21:51:18 +0000 Subject: [PATCH] Same instructions, but simpler. --- library/core/src/str/iter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/str/iter.rs b/library/core/src/str/iter.rs index 0c74f6e45a78..83f484dc570c 100644 --- a/library/core/src/str/iter.rs +++ b/library/core/src/str/iter.rs @@ -47,7 +47,7 @@ impl<'a> Iterator for Chars<'a> { #[inline] fn count(self) -> usize { // length in `char` is equal to the number of non-continuation bytes - self.iter.map(|&byte| !utf8_is_cont_byte(byte) as usize).sum() + self.iter.filter(|&&byte| !utf8_is_cont_byte(byte)).count() } #[inline]