let iter = vec![1, 2, 3].into_iter().peekable(); assert_eq!(Some(1), iter.peek()); assert_eq!(Some(3), iter.peek_back());
This seems easy to implement, but a naive implementation would add a new internal field on
Peekable which would store the back value, which would be unused in cases where
I: !DoubleEndedIterator. Is there any way to avoid that?