Skip to content

Instantly share code, notes, and snippets.

@panicbit
Created June 29, 2018 18:03
Show Gist options
  • Save panicbit/a477a75c740c6a85012eae6c98503e6f to your computer and use it in GitHub Desktop.
Save panicbit/a477a75c740c6a85012eae6c98503e6f to your computer and use it in GitHub Desktop.
struct OptionIter<I> {
iter: Option<I>,
}
impl<I> Iterator for OptionIter<I>
where
I: Iterator,
{
type Item = Option<I::Item>;
fn next(&mut self) -> Option<Self::Item> {
match self.iter {
None => return Some(None),
Some(ref mut iter) => Some(iter.next()),
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment