iterator: implement size_hint() for FlatMap
This commit is contained in:
parent
4b2931c90f
commit
5d4af58c1d
1 changed files with 10 additions and 0 deletions
|
@ -1271,6 +1271,16 @@ impl<'self, A, T: Iterator<A>, B, U: Iterator<B>> Iterator<B> for
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn size_hint(&self) -> (uint, Option<uint>) {
|
||||
let (flo, fhi) = self.frontiter.map_default((0, Some(0)), |it| it.size_hint());
|
||||
let (blo, bhi) = self.backiter.map_default((0, Some(0)), |it| it.size_hint());
|
||||
match (self.iter.size_hint(), fhi, bhi) {
|
||||
((0, Some(0)), Some(a), Some(b)) => (flo + blo, Some(a + b)),
|
||||
_ => (flo + blo, None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self,
|
||||
|
|
Loading…
Add table
Reference in a new issue