Change:
This should be in : This would require either implementing for (where ), or decoupling and (like in )

Discussion:
fn next_back(&mut self) -> Option<<I as Iterator>::Item> { self.iter.next_back() } } <ins> #[stable] impl<'a, I> ExactSizeIterator for ByRef<'a, I> where I: 'a + ExactSizeIterator {} </ins> /// A trait for iterators over elements which can be added together #[unstable = "needs to be re-evaluated as part of numerics reform"] pub trait AdditiveIterator<A> {

} #[stable] <ins> impl<T, I> ExactSizeIterator for Peekable<T, I> where I: ExactSizeIterator<Item = T> {} #[stable] </ins> impl<T, I> Peekable<T, I> where I: Iterator<Item=T> { /// Return a reference to the next element of the iterator with out advancing it, /// or None if the iterator is exhausted.

} } <ins> #[stable] impl<I> ExactSizeIterator for Skip<I> where I: ExactSizeIterator {} </ins> /// An iterator that only iterates over the first `n` iterations of `iter`. #[derive(Clone)] #[must_use = "iterator adaptors are lazy and do nothing unless consumed"]

} } <ins> #[stable] impl<I> ExactSizeIterator for Take<I> where I: ExactSizeIterator {} </ins> /// An iterator to maintain state while iterating another iterator #[must_use = "iterator adaptors are lazy and do nothing unless consumed"]

} } <ins> #[stable] impl<I> ExactSizeIterator for Fuse<I> where I: ExactSizeIterator {} </ins> impl<I> Fuse<I> { /// Resets the fuse such that the next call to .next() or .next_back() will /// call the underlying iterator again even if it previously returned None.

fn test_iterator_peekable() { let xs = vec![0u, 1, 2, 3, 4, 5]; let mut it = xs.iter().map(|&x|x).peekable(); <ins> assert_eq!(it.len(), 6); </ins> assert_eq!(it.peek().unwrap(), &0); <ins> assert_eq!(it.len(), 6); </ins> assert_eq!(it.next().unwrap(), 0); <ins> assert_eq!(it.len(), 5); </ins> assert_eq!(it.next().unwrap(), 1); <ins> assert_eq!(it.len(), 4); </ins> assert_eq!(it.next().unwrap(), 2); <ins> assert_eq!(it.len(), 3); </ins> assert_eq!(it.peek().unwrap(), &3); <ins> assert_eq!(it.len(), 3); </ins> assert_eq!(it.peek().unwrap(), &3); <ins> assert_eq!(it.len(), 3); </ins> assert_eq!(it.next().unwrap(), 3); <ins> assert_eq!(it.len(), 2); </ins> assert_eq!(it.next().unwrap(), 4); <ins> assert_eq!(it.len(), 1); </ins> assert_eq!(it.peek().unwrap(), &5); <ins> assert_eq!(it.len(), 1); </ins> assert_eq!(it.next().unwrap(), 5); <ins> assert_eq!(it.len(), 0); </ins> assert!(it.peek().is_none()); <ins> assert_eq!(it.len(), 0); </ins> assert!(it.next().is_none()); <ins> assert_eq!(it.len(), 0); </ins> } #[test]

let ys = [13, 15, 16, 17, 19, 20, 30]; let mut it = xs.iter().skip(5); let mut i = 0; <del> for &x in it { </del> <ins> while let Some(&x) = it.next() { </ins> assert_eq!(x, ys[i]); i += 1; <ins> assert_eq!(it.len(), xs.len()-5-i); </ins> } assert_eq!(i, ys.len()); <ins> assert_eq!(it.len(), 0); </ins> } #[test] fn test_iterator_take() { <del> let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19]; let ys = [0u, 1, 2, 3, 5]; </del> <ins> let xs = [0us, 1, 2, 3, 5, 13, 15, 16, 17, 19]; let ys = [0us, 1, 2, 3, 5]; </ins> let mut it = xs.iter().take(5); let mut i = 0; <del> for &x in it { </del> <ins> assert_eq!(it.len(), 5); while let Some(&x) = it.next() { assert_eq!(x, ys[i]); i += 1; assert_eq!(it.len(), 5-i); } assert_eq!(i, ys.len()); assert_eq!(it.len(), 0); } #[test] fn test_iterator_take_short() { let xs = [0us, 1, 2, 3]; let ys = [0us, 1, 2, 3]; let mut it = xs.iter().take(5); let mut i = 0; assert_eq!(it.len(), 4); while let Some(&x) = it.next() { </ins> assert_eq!(x, ys[i]); i += 1; <ins> assert_eq!(it.len(), 4-i); </ins> } assert_eq!(i, ys.len()); <ins> assert_eq!(it.len(), 0); </ins> } #[test]

assert_eq!(it.next(), Some(42u)); } <ins> #[test] fn test_fuse() { let mut it = 0us..3; assert_eq!(it.len(), 3); assert_eq!(it.next(), Some(0us)); assert_eq!(it.len(), 2); assert_eq!(it.next(), Some(1us)); assert_eq!(it.len(), 1); assert_eq!(it.next(), Some(2us)); assert_eq!(it.len(), 0); assert_eq!(it.next(), None); assert_eq!(it.len(), 0); assert_eq!(it.next(), None); assert_eq!(it.len(), 0); assert_eq!(it.next(), None); assert_eq!(it.len(), 0); } </ins> #[bench] fn bench_rposition(b: &mut Bencher) { let it: Vec<uint> = range(0u, 300).collect();