Fix incorrect lower bounds
This commit is contained in:
parent
619003d1d4
commit
8334977dcf
2 changed files with 12 additions and 2 deletions
|
|
@ -905,7 +905,12 @@ impl<I: Iterator<Item = u8>> Iterator for DecodeUtf8<I> {
|
|||
|
||||
#[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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -903,7 +903,12 @@ impl<I, T, E> Iterator for ResultShunt<I, E>
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue