1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
use void::Void;

pub trait TryIterator {
    type Item;
    type Error;
    fn try_next(&mut self) -> Result<Option<Self::Item>, Self::Error>;
}

impl<I: Iterator> TryIterator for I {
    type Item = <I as Iterator>::Item;
    type Error = Void;
    #[inline]
    fn try_next(&mut self) -> Result<Option<Self::Item>, Void> { Ok(self.next()) }
}