diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 5cb2c4be0011d..7ac4a4104c5dd 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -491,6 +491,11 @@ impl Iterator for EscapeUnicode { let n = n + self.offset; (n, Some(n)) } + + #[inline] + fn count(self) -> usize { + self.len() + } } #[stable(feature = "rust1", since = "1.7.0")] @@ -545,13 +550,9 @@ impl Iterator for EscapeDefault { } } + #[inline] fn count(self) -> usize { - match self.state { - EscapeDefaultState::Char(_) => 1, - EscapeDefaultState::Unicode(iter) => iter.count(), - EscapeDefaultState::Done => 0, - EscapeDefaultState::Backslash(_) => 2, - } + self.len() } fn nth(&mut self, n: usize) -> Option {