1
2use std::iter::FusedIterator;
3
4use GeneralIterator::*;
5
6#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
7pub enum GeneralIterator<A, B, C = A, D = A, E = A, F = A, G = A, H = A, I = A, J = A> {
8 IA(A),
9 IB(B),
10 IC(C),
11 ID(D),
12 IE(E),
13 IF(F),
14 IG(G),
15 IH(H),
16 II(I),
17 IJ(J),
18}
19
20impl<A, B, C, D, E, F, G, H, I, J, T> Iterator for GeneralIterator<A, B, C, D, E, F, G, H, I, J>
21where
22 A: Iterator<Item = T>,
23 B: Iterator<Item = T>,
24 C: Iterator<Item = T>,
25 D: Iterator<Item = T>,
26 E: Iterator<Item = T>,
27 F: Iterator<Item = T>,
28 G: Iterator<Item = T>,
29 H: Iterator<Item = T>,
30 I: Iterator<Item = T>,
31 J: Iterator<Item = T>,
32{
33 type Item = T;
34
35 #[inline(always)]
36 fn next(&mut self) -> Option<Self::Item> {
37 match self {
38 IA(i) => i.next(),
39 IB(i) => i.next(),
40 IC(i) => i.next(),
41 ID(i) => i.next(),
42 IE(i) => i.next(),
43 IF(i) => i.next(),
44 IG(i) => i.next(),
45 IH(i) => i.next(),
46 II(i) => i.next(),
47 IJ(i) => i.next(),
48 }
49 }
50}
51
52impl<A, B, C, D, E, F, G, H, I, J, T> ExactSizeIterator for GeneralIterator<A, B, C, D, E, F, G, H, I, J>
53where
54 Self: Iterator<Item = T>,
55 A: ExactSizeIterator,
56 B: ExactSizeIterator,
57 C: ExactSizeIterator,
58 D: ExactSizeIterator,
59 E: ExactSizeIterator,
60 F: ExactSizeIterator,
61 G: ExactSizeIterator,
62 H: ExactSizeIterator,
63 I: ExactSizeIterator,
64 J: ExactSizeIterator,
65{
66 #[inline(always)]
67 fn len(&self) -> usize {
68 match self {
69 IA(i) => i.len(),
70 IB(i) => i.len(),
71 IC(i) => i.len(),
72 ID(i) => i.len(),
73 IE(i) => i.len(),
74 IF(i) => i.len(),
75 IG(i) => i.len(),
76 IH(i) => i.len(),
77 II(i) => i.len(),
78 IJ(i) => i.len(),
79 }
80 }
81}
82
83impl<A, B, C, D, E, F, G, H, I, J, T> FusedIterator for GeneralIterator<A, B, C, D, E, F, G, H, I, J>
84where
85 Self: Iterator<Item = T>,
86 A: FusedIterator,
87 B: FusedIterator,
88 C: FusedIterator,
89 D: FusedIterator,
90 E: FusedIterator,
91 F: FusedIterator,
92 G: FusedIterator,
93 H: FusedIterator,
94 I: FusedIterator,
95 J: FusedIterator,
96{}
97
98impl<A, B, C, D, E, F, G, H, I, J, T> DoubleEndedIterator for GeneralIterator<A, B, C, D, E, F, G, H, I, J>
99where
100 Self: Iterator<Item = T>,
101 A: DoubleEndedIterator<Item = T>,
102 B: DoubleEndedIterator<Item = T>,
103 C: DoubleEndedIterator<Item = T>,
104 D: DoubleEndedIterator<Item = T>,
105 E: DoubleEndedIterator<Item = T>,
106 F: DoubleEndedIterator<Item = T>,
107 G: DoubleEndedIterator<Item = T>,
108 H: DoubleEndedIterator<Item = T>,
109 I: DoubleEndedIterator<Item = T>,
110 J: DoubleEndedIterator<Item = T>,
111{
112 #[inline(always)]
113 fn next_back(&mut self) -> Option<Self::Item> {
114 match self {
115 IA(i) => i.next_back(),
116 IB(i) => i.next_back(),
117 IC(i) => i.next_back(),
118 ID(i) => i.next_back(),
119 IE(i) => i.next_back(),
120 IF(i) => i.next_back(),
121 IG(i) => i.next_back(),
122 IH(i) => i.next_back(),
123 II(i) => i.next_back(),
124 IJ(i) => i.next_back(),
125 }
126 }
127}
128
129pub trait IntoGeneralIterator {
130 #[inline(always)]
131 fn type1<B, C, D, E, F, G, H, I, J>(self) -> GeneralIterator<Self, B, C, D, E, F, G, H, I, J> where Self: Sized {
132 IA(self)
133 }
134
135 #[inline(always)]
136 fn type2<A, C, D, E, F, G, H, I, J>(self) -> GeneralIterator<A, Self, C, D, E, F, G, H, I, J> where Self: Sized {
137 IB(self)
138 }
139
140 #[inline(always)]
141 fn type3<A, B, D, E, F, G, H, I, J>(self) -> GeneralIterator<A, B, Self, D, E, F, G, H, I, J> where Self: Sized {
142 IC(self)
143 }
144
145 #[inline(always)]
146 fn type4<A, B, C, E, F, G, H, I, J>(self) -> GeneralIterator<A, B, C, Self, E, F, G, H, I, J> where Self: Sized {
147 ID(self)
148 }
149
150 #[inline(always)]
151 fn type5<A, B, C, D, F, G, H, I, J>(self) -> GeneralIterator<A, B, C, D, Self, F, G, H, I, J> where Self: Sized {
152 IE(self)
153 }
154
155 #[inline(always)]
156 fn type6<A, B, C, D, E, G, H, I, J>(self) -> GeneralIterator<A, B, C, D, E, Self, G, H, I, J> where Self: Sized {
157 IF(self)
158 }
159
160 #[inline(always)]
161 fn type7<A, B, C, D, E, F, H, I, J>(self) -> GeneralIterator<A, B, C, D, E, F, Self, H, I, J> where Self: Sized {
162 IG(self)
163 }
164
165 #[inline(always)]
166 fn type8<A, B, C, D, E, F, G, I, J>(self) -> GeneralIterator<A, B, C, D, E, F, G, Self, I, J> where Self: Sized {
167 IH(self)
168 }
169
170 #[inline(always)]
171 fn type9<A, B, C, D, E, F, G, H, J>(self) -> GeneralIterator<A, B, C, D, E, F, G, H, Self, J> where Self: Sized {
172 II(self)
173 }
174
175 #[inline(always)]
176 fn type10<A, B, C, D, E, F, G, H, I>(self) -> GeneralIterator<A, B, C, D, E, F, G, H, I, Self> where Self: Sized {
177 IJ(self)
178 }
179}
180
181impl<T: Iterator> IntoGeneralIterator for T {}