// The even numbers from zero to ten. letiter = (0..10).filter(|x| x % 2 == 0);
// We might iterate from zero to ten times. Knowing that it's five // exactly wouldn't be possible without executing filter(). assert_eq!((0, Some(10)), iter.size_hint());
// Let's add five more numbers with chain() letiter = (0..10).filter(|x| x % 2 == 0).chain(15..20); // now both bounds are increased by five assert_eq!((5, Some(15)), iter.size_hint());
#[inline] fnsize_hint(&self) -> (usize, Option<usize>) { let (_, upper) = self.iter.size_hint(); (0, upper) // can't know a lower bound, due to the predicate }