Skip to main content

nanvm_lib/common/
either.rs

1pub enum Either<L, R> {
2    Left(L),
3    Right(R),
4}
5
6impl<L, R, T> Iterator for Either<L, R>
7where
8    L: Iterator<Item = T>,
9    R: Iterator<Item = T>,
10{
11    type Item = T;
12    fn next(&mut self) -> Option<T> {
13        match self {
14            Either::Left(l) => l.next(),
15            Either::Right(r) => r.next(),
16        }
17    }
18    fn size_hint(&self) -> (usize, Option<usize>) {
19        match self {
20            Either::Left(l) => l.size_hint(),
21            Either::Right(r) => r.size_hint(),
22        }
23    }
24}