iterator: implement size_hint() for FlatMap

This commit is contained in:
blake2-ppc 2013-07-20 17:10:00 +02:00
parent 4b2931c90f
commit 5d4af58c1d

View file

@ -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,