Fix incorrect lower bounds

This commit is contained in:
Phlosioneer
2018-03-24 23:35:16 -04:00
parent 619003d1d4
commit 8334977dcf
2 changed files with 12 additions and 2 deletions
+6 -1
View File
@@ -905,7 +905,12 @@ macro_rules! continuation_byte {
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
let len = self.iter.len();
// A code point is at most 4 bytes long.
let min_code_points = len / 4;
(min_code_points, Some(len))
}
}
+6 -1
View File
@@ -903,7 +903,12 @@ fn next(&mut self) -> Option<Self::Item> {
}
fn size_hint(&self) -> (usize, Option<usize>) {
self.iter.size_hint()
if self.error.is_some() {
(0, Some(0))
} else {
let (_, upper) = self.iter.size_hint();
(0, upper)
}
}
}