use auto_enums::enum_derive; enum Enum { A(A), B(B), } impl ::core::iter::Iterator for Enum where A: ::core::iter::Iterator, B: ::core::iter::Iterator::Item>, { type Item = ::Item; #[inline] fn next(&mut self) -> ::core::option::Option { match self { Enum::A(x) => ::next(x), Enum::B(x) => ::next(x), } } #[inline] fn size_hint(&self) -> (usize, ::core::option::Option) { match self { Enum::A(x) => ::size_hint(x), Enum::B(x) => ::size_hint(x), } } #[inline] fn count(self) -> usize { match self { Enum::A(x) => ::count(x), Enum::B(x) => ::count(x), } } #[inline] fn last(self) -> ::core::option::Option { match self { Enum::A(x) => ::last(x), Enum::B(x) => ::last(x), } } #[inline] fn nth(&mut self, n: usize) -> ::core::option::Option { match self { Enum::A(x) => ::nth(x, n), Enum::B(x) => ::nth(x, n), } } #[inline] #[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"] fn collect<__U: ::core::iter::FromIterator>(self) -> __U { match self { Enum::A(x) => ::collect(x), Enum::B(x) => ::collect(x), } } #[inline] fn partition<__U, __F>(self, f: __F) -> (__U, __U) where __U: ::core::default::Default + ::core::iter::Extend, __F: ::core::ops::FnMut(&Self::Item) -> bool, { match self { Enum::A(x) => ::partition(x, f), Enum::B(x) => ::partition(x, f), } } #[inline] fn fold<__U, __F>(self, init: __U, f: __F) -> __U where __F: ::core::ops::FnMut(__U, Self::Item) -> __U, { match self { Enum::A(x) => ::fold(x, init, f), Enum::B(x) => ::fold(x, init, f), } } #[inline] fn all<__F>(&mut self, f: __F) -> bool where __F: ::core::ops::FnMut(Self::Item) -> bool, { match self { Enum::A(x) => ::all(x, f), Enum::B(x) => ::all(x, f), } } #[inline] fn any<__F>(&mut self, f: __F) -> bool where __F: ::core::ops::FnMut(Self::Item) -> bool, { match self { Enum::A(x) => ::any(x, f), Enum::B(x) => ::any(x, f), } } #[inline] fn find<__P>(&mut self, predicate: __P) -> ::core::option::Option where __P: ::core::ops::FnMut(&Self::Item) -> bool, { match self { Enum::A(x) => ::find(x, predicate), Enum::B(x) => ::find(x, predicate), } } #[inline] fn find_map<__U, __F>(&mut self, f: __F) -> ::core::option::Option<__U> where __F: ::core::ops::FnMut(Self::Item) -> ::core::option::Option<__U>, { match self { Enum::A(x) => ::find_map(x, f), Enum::B(x) => ::find_map(x, f), } } #[inline] fn position<__P>(&mut self, predicate: __P) -> ::core::option::Option where __P: ::core::ops::FnMut(Self::Item) -> bool, { match self { Enum::A(x) => ::position(x, predicate), Enum::B(x) => ::position(x, predicate), } } } impl ::core::iter::FusedIterator for Enum where A: ::core::iter::FusedIterator, B: ::core::iter::FusedIterator::Item>, {} fn main() {}