Take out an insurance policy in case iter.size_hint()
lies, underreporting the number of elements.
This commit is contained in:
parent
23f890f102
commit
dfcfca28ad
1 changed files with 5 additions and 1 deletions
|
|
@ -2930,14 +2930,18 @@ impl<T, R, E> InternIteratorElement<T, R> for Result<T, E> {
|
|||
// lower bounds from `size_hint` agree they are correct.
|
||||
Ok(match iter.size_hint() {
|
||||
(1, Some(1)) => {
|
||||
f(&[iter.next().unwrap()?])
|
||||
let t0 = iter.next().unwrap()?;
|
||||
assert!(iter.next().is_none());
|
||||
f(&[t0])
|
||||
}
|
||||
(2, Some(2)) => {
|
||||
let t0 = iter.next().unwrap()?;
|
||||
let t1 = iter.next().unwrap()?;
|
||||
assert!(iter.next().is_none());
|
||||
f(&[t0, t1])
|
||||
}
|
||||
(0, Some(0)) => {
|
||||
assert!(iter.next().is_none());
|
||||
f(&[])
|
||||
}
|
||||
_ => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue