1use std::any::TypeId;
10
11pub enum Or2<T1, T2> {
13 T1(T1),
14 T2(T2),
15}
16
17impl<T1, T2> Or2<T1, T2> {
18 pub fn is_t1(&self) -> bool {
20 match self {
21 Self::T1(_) => true,
22 _ => false,
23 }
24 }
25
26 pub fn is_t2(&self) -> bool {
28 match self {
29 Self::T2(_) => true,
30 _ => false,
31 }
32 }
33
34 pub fn as_t1(self) -> Option<T1> {
36 match self {
37 Self::T1(t1) => Some(t1),
38 _ => None,
39 }
40 }
41
42 pub fn as_t2(self) -> Option<T2> {
44 match self {
45 Self::T2(t2) => Some(t2),
46 _ => None,
47 }
48 }
49
50 pub fn map_t1<F, B>(self, f: F) -> Or2<B, T2>
53 where
54 F: FnOnce(T1) -> B,
55 {
56 match self {
57 Self::T1(t1) => Or2::<B, T2>::T1(f(t1)),
58 Self::T2(t2) => Or2::<B, T2>::T2(t2),
59 }
60 }
61
62 pub fn map_t2<F, B>(self, f: F) -> Or2<T1, B>
65 where
66 F: FnOnce(T2) -> B,
67 {
68 match self {
69 Self::T1(t1) => Or2::<T1, B>::T1(t1),
70 Self::T2(t2) => Or2::<T1, B>::T2(f(t2)),
71 }
72 }
73
74 pub fn fold<T, F0, F1, F2>(self, f1: F1, f2: F2) -> T
77 where
78 F1: FnOnce(T1) -> T,
79 F2: FnOnce(T2) -> T,
80 {
81 match self {
82 Self::T1(t1) => f1(t1),
83 Self::T2(t2) => f2(t2),
84 }
85 }
86}
87
88impl<T1, T2> Or2<T1, T2>
92where
93 T1: 'static,
94 T2: 'static,
95{
96 pub fn is_type<T: 'static>(&self) -> bool {
97 match self {
98 Self::T1(_) => TypeId::of::<T>() == TypeId::of::<T1>(),
99 Self::T2(_) => TypeId::of::<T>() == TypeId::of::<T2>(),
100 }
101 }
102}
103
104#[derive(Clone, Copy)]
106pub enum Or3<T1, T2, T3> {
107 T1(T1),
108 T2(T2),
109 T3(T3),
110}
111
112impl<T1, T2, T3> Or3<T1, T2, T3> {
113 pub fn is_t1(&self) -> bool {
115 match self {
116 Self::T1(_) => true,
117 _ => false,
118 }
119 }
120
121 pub fn is_t2(&self) -> bool {
123 match self {
124 Self::T2(_) => true,
125 _ => false,
126 }
127 }
128
129 pub fn is_t3(&self) -> bool {
131 match self {
132 Self::T3(_) => true,
133 _ => false,
134 }
135 }
136
137 pub fn as_t1(self) -> Option<T1> {
139 match self {
140 Self::T1(t1) => Some(t1),
141 _ => None,
142 }
143 }
144
145 pub fn as_t2(self) -> Option<T2> {
147 match self {
148 Self::T2(t2) => Some(t2),
149 _ => None,
150 }
151 }
152
153 pub fn as_t3(self) -> Option<T3> {
155 match self {
156 Self::T3(t3) => Some(t3),
157 _ => None,
158 }
159 }
160
161 pub fn map_t1<F, B>(self, f: F) -> Or3<B, T2, T3>
164 where
165 F: FnOnce(T1) -> B,
166 {
167 match self {
168 Self::T1(t1) => Or3::<B, T2, T3>::T1(f(t1)),
169 Self::T2(t2) => Or3::<B, T2, T3>::T2(t2),
170 Self::T3(t3) => Or3::<B, T2, T3>::T3(t3),
171 }
172 }
173
174 pub fn map_t2<F, B>(self, f: F) -> Or3<T1, B, T3>
177 where
178 F: FnOnce(T2) -> B,
179 {
180 match self {
181 Self::T1(t1) => Or3::<T1, B, T3>::T1(t1),
182 Self::T2(t2) => Or3::<T1, B, T3>::T2(f(t2)),
183 Self::T3(t3) => Or3::<T1, B, T3>::T3(t3),
184 }
185 }
186
187 pub fn map_t3<F, B>(self, f: F) -> Or3<T1, T2, B>
190 where
191 F: FnOnce(T3) -> B,
192 {
193 match self {
194 Self::T1(t1) => Or3::<T1, T2, B>::T1(t1),
195 Self::T2(t2) => Or3::<T1, T2, B>::T2(t2),
196 Self::T3(t3) => Or3::<T1, T2, B>::T3(f(t3)),
197 }
198 }
199
200 pub fn fold<T, F0, F1, F2, F3>(self, f1: F1, f2: F2, f3: F3) -> T
203 where
204 F1: FnOnce(T1) -> T,
205 F2: FnOnce(T2) -> T,
206 F3: FnOnce(T3) -> T,
207 {
208 match self {
209 Self::T1(t1) => f1(t1),
210 Self::T2(t2) => f2(t2),
211 Self::T3(t3) => f3(t3),
212 }
213 }
214}
215
216impl<T1, T2, T3> Or3<T1, T2, T3>
220where
221 T1: 'static,
222 T2: 'static,
223 T3: 'static,
224{
225 pub fn is_type<T: 'static>(&self) -> bool {
226 match self {
227 Self::T1(_) => TypeId::of::<T>() == TypeId::of::<T1>(),
228 Self::T2(_) => TypeId::of::<T>() == TypeId::of::<T2>(),
229 Self::T3(_) => TypeId::of::<T>() == TypeId::of::<T3>(),
230 }
231 }
232}
233
234pub enum Or4<T1, T2, T3, T4> {
236 T1(T1),
237 T2(T2),
238 T3(T3),
239 T4(T4),
240}
241
242impl<T1, T2, T3, T4> Or4<T1, T2, T3, T4> {
243 pub fn is_t1(&self) -> bool {
245 match self {
246 Self::T1(_) => true,
247 _ => false,
248 }
249 }
250
251 pub fn is_t2(&self) -> bool {
253 match self {
254 Self::T2(_) => true,
255 _ => false,
256 }
257 }
258
259 pub fn is_t3(&self) -> bool {
261 match self {
262 Self::T3(_) => true,
263 _ => false,
264 }
265 }
266
267 pub fn is_t4(&self) -> bool {
269 match self {
270 Self::T4(_) => true,
271 _ => false,
272 }
273 }
274
275 pub fn as_t1(self) -> Option<T1> {
277 match self {
278 Self::T1(t1) => Some(t1),
279 _ => None,
280 }
281 }
282
283 pub fn as_t2(self) -> Option<T2> {
285 match self {
286 Self::T2(t2) => Some(t2),
287 _ => None,
288 }
289 }
290
291 pub fn as_t3(self) -> Option<T3> {
293 match self {
294 Self::T3(t3) => Some(t3),
295 _ => None,
296 }
297 }
298
299 pub fn as_t4(self) -> Option<T4> {
301 match self {
302 Self::T4(t4) => Some(t4),
303 _ => None,
304 }
305 }
306
307 pub fn map_t1<F, B>(self, f: F) -> Or4<B, T2, T3, T4>
310 where
311 F: FnOnce(T1) -> B,
312 {
313 match self {
314 Self::T1(t1) => Or4::<B, T2, T3, T4>::T1(f(t1)),
315 Self::T2(t2) => Or4::<B, T2, T3, T4>::T2(t2),
316 Self::T3(t3) => Or4::<B, T2, T3, T4>::T3(t3),
317 Self::T4(t4) => Or4::<B, T2, T3, T4>::T4(t4),
318 }
319 }
320
321 pub fn map_t2<F, B>(self, f: F) -> Or4<T1, B, T3, T4>
324 where
325 F: FnOnce(T2) -> B,
326 {
327 match self {
328 Self::T1(t1) => Or4::<T1, B, T3, T4>::T1(t1),
329 Self::T2(t2) => Or4::<T1, B, T3, T4>::T2(f(t2)),
330 Self::T3(t3) => Or4::<T1, B, T3, T4>::T3(t3),
331 Self::T4(t4) => Or4::<T1, B, T3, T4>::T4(t4),
332 }
333 }
334
335 pub fn map_t3<F, B>(self, f: F) -> Or4<T1, T2, B, T4>
338 where
339 F: FnOnce(T3) -> B,
340 {
341 match self {
342 Self::T1(t1) => Or4::<T1, T2, B, T4>::T1(t1),
343 Self::T2(t2) => Or4::<T1, T2, B, T4>::T2(t2),
344 Self::T3(t3) => Or4::<T1, T2, B, T4>::T3(f(t3)),
345 Self::T4(t4) => Or4::<T1, T2, B, T4>::T4(t4),
346 }
347 }
348
349 pub fn map_t4<F, B>(self, f: F) -> Or4<T1, T2, T3, B>
352 where
353 F: FnOnce(T4) -> B,
354 {
355 match self {
356 Self::T1(t1) => Or4::<T1, T2, T3, B>::T1(t1),
357 Self::T2(t2) => Or4::<T1, T2, T3, B>::T2(t2),
358 Self::T3(t3) => Or4::<T1, T2, T3, B>::T3(t3),
359 Self::T4(t4) => Or4::<T1, T2, T3, B>::T4(f(t4)),
360 }
361 }
362
363 pub fn fold<T, F0, F1, F2, F3, F4>(self, f1: F1, f2: F2, f3: F3, f4: F4) -> T
366 where
367 F1: FnOnce(T1) -> T,
368 F2: FnOnce(T2) -> T,
369 F3: FnOnce(T3) -> T,
370 F4: FnOnce(T4) -> T,
371 {
372 match self {
373 Self::T1(t1) => f1(t1),
374 Self::T2(t2) => f2(t2),
375 Self::T3(t3) => f3(t3),
376 Self::T4(t4) => f4(t4),
377 }
378 }
379}
380
381impl<T1, T2, T3, T4> Or4<T1, T2, T3, T4>
385where
386 T1: 'static,
387 T2: 'static,
388 T3: 'static,
389 T4: 'static,
390{
391 pub fn is_type<T: 'static>(&self) -> bool {
392 match self {
393 Self::T1(_) => TypeId::of::<T>() == TypeId::of::<T1>(),
394 Self::T2(_) => TypeId::of::<T>() == TypeId::of::<T2>(),
395 Self::T3(_) => TypeId::of::<T>() == TypeId::of::<T3>(),
396 Self::T4(_) => TypeId::of::<T>() == TypeId::of::<T4>(),
397 }
398 }
399}
400
401pub enum Or5<T1, T2, T3, T4, T5> {
403 T1(T1),
404 T2(T2),
405 T3(T3),
406 T4(T4),
407 T5(T5),
408}
409
410impl<T1, T2, T3, T4, T5> Or5<T1, T2, T3, T4, T5> {
411 pub fn is_t1(&self) -> bool {
413 match self {
414 Self::T1(_) => true,
415 _ => false,
416 }
417 }
418
419 pub fn is_t2(&self) -> bool {
421 match self {
422 Self::T2(_) => true,
423 _ => false,
424 }
425 }
426
427 pub fn is_t3(&self) -> bool {
429 match self {
430 Self::T3(_) => true,
431 _ => false,
432 }
433 }
434
435 pub fn is_t4(&self) -> bool {
437 match self {
438 Self::T4(_) => true,
439 _ => false,
440 }
441 }
442
443 pub fn is_t5(&self) -> bool {
445 match self {
446 Self::T5(_) => true,
447 _ => false,
448 }
449 }
450
451 pub fn as_t1(self) -> Option<T1> {
453 match self {
454 Self::T1(t1) => Some(t1),
455 _ => None,
456 }
457 }
458
459 pub fn as_t2(self) -> Option<T2> {
461 match self {
462 Self::T2(t2) => Some(t2),
463 _ => None,
464 }
465 }
466
467 pub fn as_t3(self) -> Option<T3> {
469 match self {
470 Self::T3(t3) => Some(t3),
471 _ => None,
472 }
473 }
474
475 pub fn as_t4(self) -> Option<T4> {
477 match self {
478 Self::T4(t4) => Some(t4),
479 _ => None,
480 }
481 }
482
483 pub fn as_t5(self) -> Option<T5> {
485 match self {
486 Self::T5(t5) => Some(t5),
487 _ => None,
488 }
489 }
490
491 pub fn map_t1<F, B>(self, f: F) -> Or5<B, T2, T3, T4, T5>
494 where
495 F: FnOnce(T1) -> B,
496 {
497 match self {
498 Self::T1(t1) => Or5::<B, T2, T3, T4, T5>::T1(f(t1)),
499 Self::T2(t2) => Or5::<B, T2, T3, T4, T5>::T2(t2),
500 Self::T3(t3) => Or5::<B, T2, T3, T4, T5>::T3(t3),
501 Self::T4(t4) => Or5::<B, T2, T3, T4, T5>::T4(t4),
502 Self::T5(t5) => Or5::<B, T2, T3, T4, T5>::T5(t5),
503 }
504 }
505
506 pub fn map_t2<F, B>(self, f: F) -> Or5<T1, B, T3, T4, T5>
509 where
510 F: FnOnce(T2) -> B,
511 {
512 match self {
513 Self::T1(t1) => Or5::<T1, B, T3, T4, T5>::T1(t1),
514 Self::T2(t2) => Or5::<T1, B, T3, T4, T5>::T2(f(t2)),
515 Self::T3(t3) => Or5::<T1, B, T3, T4, T5>::T3(t3),
516 Self::T4(t4) => Or5::<T1, B, T3, T4, T5>::T4(t4),
517 Self::T5(t5) => Or5::<T1, B, T3, T4, T5>::T5(t5),
518 }
519 }
520
521 pub fn map_t3<F, B>(self, f: F) -> Or5<T1, T2, B, T4, T5>
524 where
525 F: FnOnce(T3) -> B,
526 {
527 match self {
528 Self::T1(t1) => Or5::<T1, T2, B, T4, T5>::T1(t1),
529 Self::T2(t2) => Or5::<T1, T2, B, T4, T5>::T2(t2),
530 Self::T3(t3) => Or5::<T1, T2, B, T4, T5>::T3(f(t3)),
531 Self::T4(t4) => Or5::<T1, T2, B, T4, T5>::T4(t4),
532 Self::T5(t5) => Or5::<T1, T2, B, T4, T5>::T5(t5),
533 }
534 }
535
536 pub fn map_t4<F, B>(self, f: F) -> Or5<T1, T2, T3, B, T5>
539 where
540 F: FnOnce(T4) -> B,
541 {
542 match self {
543 Self::T1(t1) => Or5::<T1, T2, T3, B, T5>::T1(t1),
544 Self::T2(t2) => Or5::<T1, T2, T3, B, T5>::T2(t2),
545 Self::T3(t3) => Or5::<T1, T2, T3, B, T5>::T3(t3),
546 Self::T4(t4) => Or5::<T1, T2, T3, B, T5>::T4(f(t4)),
547 Self::T5(t5) => Or5::<T1, T2, T3, B, T5>::T5(t5),
548 }
549 }
550
551 pub fn map_t5<F, B>(self, f: F) -> Or5<T1, T2, T3, T4, B>
554 where
555 F: FnOnce(T5) -> B,
556 {
557 match self {
558 Self::T1(t1) => Or5::<T1, T2, T3, T4, B>::T1(t1),
559 Self::T2(t2) => Or5::<T1, T2, T3, T4, B>::T2(t2),
560 Self::T3(t3) => Or5::<T1, T2, T3, T4, B>::T3(t3),
561 Self::T4(t4) => Or5::<T1, T2, T3, T4, B>::T4(t4),
562 Self::T5(t5) => Or5::<T1, T2, T3, T4, B>::T5(f(t5)),
563 }
564 }
565
566 pub fn fold<T, F0, F1, F2, F3, F4, F5>(self, f1: F1, f2: F2, f3: F3, f4: F4, f5: F5) -> T
569 where
570 F1: FnOnce(T1) -> T,
571 F2: FnOnce(T2) -> T,
572 F3: FnOnce(T3) -> T,
573 F4: FnOnce(T4) -> T,
574 F5: FnOnce(T5) -> T,
575 {
576 match self {
577 Self::T1(t1) => f1(t1),
578 Self::T2(t2) => f2(t2),
579 Self::T3(t3) => f3(t3),
580 Self::T4(t4) => f4(t4),
581 Self::T5(t5) => f5(t5),
582 }
583 }
584}
585
586impl<T1, T2, T3, T4, T5> Or5<T1, T2, T3, T4, T5>
590where
591 T1: 'static,
592 T2: 'static,
593 T3: 'static,
594 T4: 'static,
595 T5: 'static,
596{
597 pub fn is_type<T: 'static>(&self) -> bool {
598 match self {
599 Self::T1(_) => TypeId::of::<T>() == TypeId::of::<T1>(),
600 Self::T2(_) => TypeId::of::<T>() == TypeId::of::<T2>(),
601 Self::T3(_) => TypeId::of::<T>() == TypeId::of::<T3>(),
602 Self::T4(_) => TypeId::of::<T>() == TypeId::of::<T4>(),
603 Self::T5(_) => TypeId::of::<T>() == TypeId::of::<T5>(),
604 }
605 }
606}
607
608pub enum Or6<T1, T2, T3, T4, T5, T6> {
610 T1(T1),
611 T2(T2),
612 T3(T3),
613 T4(T4),
614 T5(T5),
615 T6(T6),
616}
617
618impl<T1, T2, T3, T4, T5, T6> Or6<T1, T2, T3, T4, T5, T6> {
619 pub fn is_t1(&self) -> bool {
621 match self {
622 Self::T1(_) => true,
623 _ => false,
624 }
625 }
626
627 pub fn is_t2(&self) -> bool {
629 match self {
630 Self::T2(_) => true,
631 _ => false,
632 }
633 }
634
635 pub fn is_t3(&self) -> bool {
637 match self {
638 Self::T3(_) => true,
639 _ => false,
640 }
641 }
642
643 pub fn is_t4(&self) -> bool {
645 match self {
646 Self::T4(_) => true,
647 _ => false,
648 }
649 }
650
651 pub fn is_t5(&self) -> bool {
653 match self {
654 Self::T5(_) => true,
655 _ => false,
656 }
657 }
658
659 pub fn is_t6(&self) -> bool {
661 match self {
662 Self::T6(_) => true,
663 _ => false,
664 }
665 }
666
667 pub fn as_t1(self) -> Option<T1> {
669 match self {
670 Self::T1(t1) => Some(t1),
671 _ => None,
672 }
673 }
674
675 pub fn as_t2(self) -> Option<T2> {
677 match self {
678 Self::T2(t2) => Some(t2),
679 _ => None,
680 }
681 }
682
683 pub fn as_t3(self) -> Option<T3> {
685 match self {
686 Self::T3(t3) => Some(t3),
687 _ => None,
688 }
689 }
690
691 pub fn as_t4(self) -> Option<T4> {
693 match self {
694 Self::T4(t4) => Some(t4),
695 _ => None,
696 }
697 }
698
699 pub fn as_t5(self) -> Option<T5> {
701 match self {
702 Self::T5(t5) => Some(t5),
703 _ => None,
704 }
705 }
706
707 pub fn as_t6(self) -> Option<T6> {
709 match self {
710 Self::T6(t6) => Some(t6),
711 _ => None,
712 }
713 }
714
715 pub fn map_t1<F, B>(self, f: F) -> Or6<B, T2, T3, T4, T5, T6>
718 where
719 F: FnOnce(T1) -> B,
720 {
721 match self {
722 Self::T1(t1) => Or6::<B, T2, T3, T4, T5, T6>::T1(f(t1)),
723 Self::T2(t2) => Or6::<B, T2, T3, T4, T5, T6>::T2(t2),
724 Self::T3(t3) => Or6::<B, T2, T3, T4, T5, T6>::T3(t3),
725 Self::T4(t4) => Or6::<B, T2, T3, T4, T5, T6>::T4(t4),
726 Self::T5(t5) => Or6::<B, T2, T3, T4, T5, T6>::T5(t5),
727 Self::T6(t6) => Or6::<B, T2, T3, T4, T5, T6>::T6(t6),
728 }
729 }
730
731 pub fn map_t2<F, B>(self, f: F) -> Or6<T1, B, T3, T4, T5, T6>
734 where
735 F: FnOnce(T2) -> B,
736 {
737 match self {
738 Self::T1(t1) => Or6::<T1, B, T3, T4, T5, T6>::T1(t1),
739 Self::T2(t2) => Or6::<T1, B, T3, T4, T5, T6>::T2(f(t2)),
740 Self::T3(t3) => Or6::<T1, B, T3, T4, T5, T6>::T3(t3),
741 Self::T4(t4) => Or6::<T1, B, T3, T4, T5, T6>::T4(t4),
742 Self::T5(t5) => Or6::<T1, B, T3, T4, T5, T6>::T5(t5),
743 Self::T6(t6) => Or6::<T1, B, T3, T4, T5, T6>::T6(t6),
744 }
745 }
746
747 pub fn map_t3<F, B>(self, f: F) -> Or6<T1, T2, B, T4, T5, T6>
750 where
751 F: FnOnce(T3) -> B,
752 {
753 match self {
754 Self::T1(t1) => Or6::<T1, T2, B, T4, T5, T6>::T1(t1),
755 Self::T2(t2) => Or6::<T1, T2, B, T4, T5, T6>::T2(t2),
756 Self::T3(t3) => Or6::<T1, T2, B, T4, T5, T6>::T3(f(t3)),
757 Self::T4(t4) => Or6::<T1, T2, B, T4, T5, T6>::T4(t4),
758 Self::T5(t5) => Or6::<T1, T2, B, T4, T5, T6>::T5(t5),
759 Self::T6(t6) => Or6::<T1, T2, B, T4, T5, T6>::T6(t6),
760 }
761 }
762
763 pub fn map_t4<F, B>(self, f: F) -> Or6<T1, T2, T3, B, T5, T6>
766 where
767 F: FnOnce(T4) -> B,
768 {
769 match self {
770 Self::T1(t1) => Or6::<T1, T2, T3, B, T5, T6>::T1(t1),
771 Self::T2(t2) => Or6::<T1, T2, T3, B, T5, T6>::T2(t2),
772 Self::T3(t3) => Or6::<T1, T2, T3, B, T5, T6>::T3(t3),
773 Self::T4(t4) => Or6::<T1, T2, T3, B, T5, T6>::T4(f(t4)),
774 Self::T5(t5) => Or6::<T1, T2, T3, B, T5, T6>::T5(t5),
775 Self::T6(t6) => Or6::<T1, T2, T3, B, T5, T6>::T6(t6),
776 }
777 }
778
779 pub fn map_t5<F, B>(self, f: F) -> Or6<T1, T2, T3, T4, B, T6>
782 where
783 F: FnOnce(T5) -> B,
784 {
785 match self {
786 Self::T1(t1) => Or6::<T1, T2, T3, T4, B, T6>::T1(t1),
787 Self::T2(t2) => Or6::<T1, T2, T3, T4, B, T6>::T2(t2),
788 Self::T3(t3) => Or6::<T1, T2, T3, T4, B, T6>::T3(t3),
789 Self::T4(t4) => Or6::<T1, T2, T3, T4, B, T6>::T4(t4),
790 Self::T5(t5) => Or6::<T1, T2, T3, T4, B, T6>::T5(f(t5)),
791 Self::T6(t6) => Or6::<T1, T2, T3, T4, B, T6>::T6(t6),
792 }
793 }
794
795 pub fn map_t6<F, B>(self, f: F) -> Or6<T1, T2, T3, T4, T5, B>
798 where
799 F: FnOnce(T6) -> B,
800 {
801 match self {
802 Self::T1(t1) => Or6::<T1, T2, T3, T4, T5, B>::T1(t1),
803 Self::T2(t2) => Or6::<T1, T2, T3, T4, T5, B>::T2(t2),
804 Self::T3(t3) => Or6::<T1, T2, T3, T4, T5, B>::T3(t3),
805 Self::T4(t4) => Or6::<T1, T2, T3, T4, T5, B>::T4(t4),
806 Self::T5(t5) => Or6::<T1, T2, T3, T4, T5, B>::T5(t5),
807 Self::T6(t6) => Or6::<T1, T2, T3, T4, T5, B>::T6(f(t6)),
808 }
809 }
810
811 pub fn fold<T, F0, F1, F2, F3, F4, F5, F6>(
814 self,
815 f1: F1,
816 f2: F2,
817 f3: F3,
818 f4: F4,
819 f5: F5,
820 f6: F6,
821 ) -> T
822 where
823 F1: FnOnce(T1) -> T,
824 F2: FnOnce(T2) -> T,
825 F3: FnOnce(T3) -> T,
826 F4: FnOnce(T4) -> T,
827 F5: FnOnce(T5) -> T,
828 F6: FnOnce(T6) -> T,
829 {
830 match self {
831 Self::T1(t1) => f1(t1),
832 Self::T2(t2) => f2(t2),
833 Self::T3(t3) => f3(t3),
834 Self::T4(t4) => f4(t4),
835 Self::T5(t5) => f5(t5),
836 Self::T6(t6) => f6(t6),
837 }
838 }
839}
840
841impl<T1, T2, T3, T4, T5, T6> Or6<T1, T2, T3, T4, T5, T6>
845where
846 T1: 'static,
847 T2: 'static,
848 T3: 'static,
849 T4: 'static,
850 T5: 'static,
851 T6: 'static,
852{
853 pub fn is_type<T: 'static>(&self) -> bool {
854 match self {
855 Self::T1(_) => TypeId::of::<T>() == TypeId::of::<T1>(),
856 Self::T2(_) => TypeId::of::<T>() == TypeId::of::<T2>(),
857 Self::T3(_) => TypeId::of::<T>() == TypeId::of::<T3>(),
858 Self::T4(_) => TypeId::of::<T>() == TypeId::of::<T4>(),
859 Self::T5(_) => TypeId::of::<T>() == TypeId::of::<T5>(),
860 Self::T6(_) => TypeId::of::<T>() == TypeId::of::<T6>(),
861 }
862 }
863}
864
865pub enum Or7<T1, T2, T3, T4, T5, T6, T7> {
867 T1(T1),
868 T2(T2),
869 T3(T3),
870 T4(T4),
871 T5(T5),
872 T6(T6),
873 T7(T7),
874}
875
876impl<T1, T2, T3, T4, T5, T6, T7> Or7<T1, T2, T3, T4, T5, T6, T7> {
877 pub fn is_t1(&self) -> bool {
879 match self {
880 Self::T1(_) => true,
881 _ => false,
882 }
883 }
884
885 pub fn is_t2(&self) -> bool {
887 match self {
888 Self::T2(_) => true,
889 _ => false,
890 }
891 }
892
893 pub fn is_t3(&self) -> bool {
895 match self {
896 Self::T3(_) => true,
897 _ => false,
898 }
899 }
900
901 pub fn is_t4(&self) -> bool {
903 match self {
904 Self::T4(_) => true,
905 _ => false,
906 }
907 }
908
909 pub fn is_t5(&self) -> bool {
911 match self {
912 Self::T5(_) => true,
913 _ => false,
914 }
915 }
916
917 pub fn is_t6(&self) -> bool {
919 match self {
920 Self::T6(_) => true,
921 _ => false,
922 }
923 }
924
925 pub fn is_t7(&self) -> bool {
927 match self {
928 Self::T7(_) => true,
929 _ => false,
930 }
931 }
932
933 pub fn as_t1(self) -> Option<T1> {
935 match self {
936 Self::T1(t1) => Some(t1),
937 _ => None,
938 }
939 }
940
941 pub fn as_t2(self) -> Option<T2> {
943 match self {
944 Self::T2(t2) => Some(t2),
945 _ => None,
946 }
947 }
948
949 pub fn as_t3(self) -> Option<T3> {
951 match self {
952 Self::T3(t3) => Some(t3),
953 _ => None,
954 }
955 }
956
957 pub fn as_t4(self) -> Option<T4> {
959 match self {
960 Self::T4(t4) => Some(t4),
961 _ => None,
962 }
963 }
964
965 pub fn as_t5(self) -> Option<T5> {
967 match self {
968 Self::T5(t5) => Some(t5),
969 _ => None,
970 }
971 }
972
973 pub fn as_t6(self) -> Option<T6> {
975 match self {
976 Self::T6(t6) => Some(t6),
977 _ => None,
978 }
979 }
980
981 pub fn as_t7(self) -> Option<T7> {
983 match self {
984 Self::T7(t7) => Some(t7),
985 _ => None,
986 }
987 }
988
989 pub fn map_t1<F, B>(self, f: F) -> Or7<B, T2, T3, T4, T5, T6, T7>
992 where
993 F: FnOnce(T1) -> B,
994 {
995 match self {
996 Self::T1(t1) => Or7::<B, T2, T3, T4, T5, T6, T7>::T1(f(t1)),
997 Self::T2(t2) => Or7::<B, T2, T3, T4, T5, T6, T7>::T2(t2),
998 Self::T3(t3) => Or7::<B, T2, T3, T4, T5, T6, T7>::T3(t3),
999 Self::T4(t4) => Or7::<B, T2, T3, T4, T5, T6, T7>::T4(t4),
1000 Self::T5(t5) => Or7::<B, T2, T3, T4, T5, T6, T7>::T5(t5),
1001 Self::T6(t6) => Or7::<B, T2, T3, T4, T5, T6, T7>::T6(t6),
1002 Self::T7(t7) => Or7::<B, T2, T3, T4, T5, T6, T7>::T7(t7),
1003 }
1004 }
1005
1006 pub fn map_t2<F, B>(self, f: F) -> Or7<T1, B, T3, T4, T5, T6, T7>
1009 where
1010 F: FnOnce(T2) -> B,
1011 {
1012 match self {
1013 Self::T1(t1) => Or7::<T1, B, T3, T4, T5, T6, T7>::T1(t1),
1014 Self::T2(t2) => Or7::<T1, B, T3, T4, T5, T6, T7>::T2(f(t2)),
1015 Self::T3(t3) => Or7::<T1, B, T3, T4, T5, T6, T7>::T3(t3),
1016 Self::T4(t4) => Or7::<T1, B, T3, T4, T5, T6, T7>::T4(t4),
1017 Self::T5(t5) => Or7::<T1, B, T3, T4, T5, T6, T7>::T5(t5),
1018 Self::T6(t6) => Or7::<T1, B, T3, T4, T5, T6, T7>::T6(t6),
1019 Self::T7(t7) => Or7::<T1, B, T3, T4, T5, T6, T7>::T7(t7),
1020 }
1021 }
1022
1023 pub fn map_t3<F, B>(self, f: F) -> Or7<T1, T2, B, T4, T5, T6, T7>
1026 where
1027 F: FnOnce(T3) -> B,
1028 {
1029 match self {
1030 Self::T1(t1) => Or7::<T1, T2, B, T4, T5, T6, T7>::T1(t1),
1031 Self::T2(t2) => Or7::<T1, T2, B, T4, T5, T6, T7>::T2(t2),
1032 Self::T3(t3) => Or7::<T1, T2, B, T4, T5, T6, T7>::T3(f(t3)),
1033 Self::T4(t4) => Or7::<T1, T2, B, T4, T5, T6, T7>::T4(t4),
1034 Self::T5(t5) => Or7::<T1, T2, B, T4, T5, T6, T7>::T5(t5),
1035 Self::T6(t6) => Or7::<T1, T2, B, T4, T5, T6, T7>::T6(t6),
1036 Self::T7(t7) => Or7::<T1, T2, B, T4, T5, T6, T7>::T7(t7),
1037 }
1038 }
1039
1040 pub fn map_t4<F, B>(self, f: F) -> Or7<T1, T2, T3, B, T5, T6, T7>
1043 where
1044 F: FnOnce(T4) -> B,
1045 {
1046 match self {
1047 Self::T1(t1) => Or7::<T1, T2, T3, B, T5, T6, T7>::T1(t1),
1048 Self::T2(t2) => Or7::<T1, T2, T3, B, T5, T6, T7>::T2(t2),
1049 Self::T3(t3) => Or7::<T1, T2, T3, B, T5, T6, T7>::T3(t3),
1050 Self::T4(t4) => Or7::<T1, T2, T3, B, T5, T6, T7>::T4(f(t4)),
1051 Self::T5(t5) => Or7::<T1, T2, T3, B, T5, T6, T7>::T5(t5),
1052 Self::T6(t6) => Or7::<T1, T2, T3, B, T5, T6, T7>::T6(t6),
1053 Self::T7(t7) => Or7::<T1, T2, T3, B, T5, T6, T7>::T7(t7),
1054 }
1055 }
1056
1057 pub fn map_t5<F, B>(self, f: F) -> Or7<T1, T2, T3, T4, B, T6, T7>
1060 where
1061 F: FnOnce(T5) -> B,
1062 {
1063 match self {
1064 Self::T1(t1) => Or7::<T1, T2, T3, T4, B, T6, T7>::T1(t1),
1065 Self::T2(t2) => Or7::<T1, T2, T3, T4, B, T6, T7>::T2(t2),
1066 Self::T3(t3) => Or7::<T1, T2, T3, T4, B, T6, T7>::T3(t3),
1067 Self::T4(t4) => Or7::<T1, T2, T3, T4, B, T6, T7>::T4(t4),
1068 Self::T5(t5) => Or7::<T1, T2, T3, T4, B, T6, T7>::T5(f(t5)),
1069 Self::T6(t6) => Or7::<T1, T2, T3, T4, B, T6, T7>::T6(t6),
1070 Self::T7(t7) => Or7::<T1, T2, T3, T4, B, T6, T7>::T7(t7),
1071 }
1072 }
1073
1074 pub fn map_t6<F, B>(self, f: F) -> Or7<T1, T2, T3, T4, T5, B, T7>
1077 where
1078 F: FnOnce(T6) -> B,
1079 {
1080 match self {
1081 Self::T1(t1) => Or7::<T1, T2, T3, T4, T5, B, T7>::T1(t1),
1082 Self::T2(t2) => Or7::<T1, T2, T3, T4, T5, B, T7>::T2(t2),
1083 Self::T3(t3) => Or7::<T1, T2, T3, T4, T5, B, T7>::T3(t3),
1084 Self::T4(t4) => Or7::<T1, T2, T3, T4, T5, B, T7>::T4(t4),
1085 Self::T5(t5) => Or7::<T1, T2, T3, T4, T5, B, T7>::T5(t5),
1086 Self::T6(t6) => Or7::<T1, T2, T3, T4, T5, B, T7>::T6(f(t6)),
1087 Self::T7(t7) => Or7::<T1, T2, T3, T4, T5, B, T7>::T7(t7),
1088 }
1089 }
1090
1091 pub fn map_t7<F, B>(self, f: F) -> Or7<T1, T2, T3, T4, T5, T6, B>
1094 where
1095 F: FnOnce(T7) -> B,
1096 {
1097 match self {
1098 Self::T1(t1) => Or7::<T1, T2, T3, T4, T5, T6, B>::T1(t1),
1099 Self::T2(t2) => Or7::<T1, T2, T3, T4, T5, T6, B>::T2(t2),
1100 Self::T3(t3) => Or7::<T1, T2, T3, T4, T5, T6, B>::T3(t3),
1101 Self::T4(t4) => Or7::<T1, T2, T3, T4, T5, T6, B>::T4(t4),
1102 Self::T5(t5) => Or7::<T1, T2, T3, T4, T5, T6, B>::T5(t5),
1103 Self::T6(t6) => Or7::<T1, T2, T3, T4, T5, T6, B>::T6(t6),
1104 Self::T7(t7) => Or7::<T1, T2, T3, T4, T5, T6, B>::T7(f(t7)),
1105 }
1106 }
1107
1108 pub fn fold<T, F0, F1, F2, F3, F4, F5, F6, F7>(
1111 self,
1112 f1: F1,
1113 f2: F2,
1114 f3: F3,
1115 f4: F4,
1116 f5: F5,
1117 f6: F6,
1118 f7: F7,
1119 ) -> T
1120 where
1121 F1: FnOnce(T1) -> T,
1122 F2: FnOnce(T2) -> T,
1123 F3: FnOnce(T3) -> T,
1124 F4: FnOnce(T4) -> T,
1125 F5: FnOnce(T5) -> T,
1126 F6: FnOnce(T6) -> T,
1127 F7: FnOnce(T7) -> T,
1128 {
1129 match self {
1130 Self::T1(t1) => f1(t1),
1131 Self::T2(t2) => f2(t2),
1132 Self::T3(t3) => f3(t3),
1133 Self::T4(t4) => f4(t4),
1134 Self::T5(t5) => f5(t5),
1135 Self::T6(t6) => f6(t6),
1136 Self::T7(t7) => f7(t7),
1137 }
1138 }
1139}
1140
1141impl<T1, T2, T3, T4, T5, T6, T7> Or7<T1, T2, T3, T4, T5, T6, T7>
1145where
1146 T1: 'static,
1147 T2: 'static,
1148 T3: 'static,
1149 T4: 'static,
1150 T5: 'static,
1151 T6: 'static,
1152 T7: 'static,
1153{
1154 pub fn is_type<T: 'static>(&self) -> bool {
1155 match self {
1156 Self::T1(_) => TypeId::of::<T>() == TypeId::of::<T1>(),
1157 Self::T2(_) => TypeId::of::<T>() == TypeId::of::<T2>(),
1158 Self::T3(_) => TypeId::of::<T>() == TypeId::of::<T3>(),
1159 Self::T4(_) => TypeId::of::<T>() == TypeId::of::<T4>(),
1160 Self::T5(_) => TypeId::of::<T>() == TypeId::of::<T5>(),
1161 Self::T6(_) => TypeId::of::<T>() == TypeId::of::<T6>(),
1162 Self::T7(_) => TypeId::of::<T>() == TypeId::of::<T7>(),
1163 }
1164 }
1165}
1166
1167pub enum Or8<T1, T2, T3, T4, T5, T6, T7, T8> {
1169 T1(T1),
1170 T2(T2),
1171 T3(T3),
1172 T4(T4),
1173 T5(T5),
1174 T6(T6),
1175 T7(T7),
1176 T8(T8),
1177}
1178
1179impl<T1, T2, T3, T4, T5, T6, T7, T8> Or8<T1, T2, T3, T4, T5, T6, T7, T8> {
1180 pub fn is_t1(&self) -> bool {
1182 match self {
1183 Self::T1(_) => true,
1184 _ => false,
1185 }
1186 }
1187
1188 pub fn is_t2(&self) -> bool {
1190 match self {
1191 Self::T2(_) => true,
1192 _ => false,
1193 }
1194 }
1195
1196 pub fn is_t3(&self) -> bool {
1198 match self {
1199 Self::T3(_) => true,
1200 _ => false,
1201 }
1202 }
1203
1204 pub fn is_t4(&self) -> bool {
1206 match self {
1207 Self::T4(_) => true,
1208 _ => false,
1209 }
1210 }
1211
1212 pub fn is_t5(&self) -> bool {
1214 match self {
1215 Self::T5(_) => true,
1216 _ => false,
1217 }
1218 }
1219
1220 pub fn is_t6(&self) -> bool {
1222 match self {
1223 Self::T6(_) => true,
1224 _ => false,
1225 }
1226 }
1227
1228 pub fn is_t7(&self) -> bool {
1230 match self {
1231 Self::T7(_) => true,
1232 _ => false,
1233 }
1234 }
1235
1236 pub fn is_t8(&self) -> bool {
1238 match self {
1239 Self::T8(_) => true,
1240 _ => false,
1241 }
1242 }
1243
1244 pub fn as_t1(self) -> Option<T1> {
1246 match self {
1247 Self::T1(t1) => Some(t1),
1248 _ => None,
1249 }
1250 }
1251
1252 pub fn as_t2(self) -> Option<T2> {
1254 match self {
1255 Self::T2(t2) => Some(t2),
1256 _ => None,
1257 }
1258 }
1259
1260 pub fn as_t3(self) -> Option<T3> {
1262 match self {
1263 Self::T3(t3) => Some(t3),
1264 _ => None,
1265 }
1266 }
1267
1268 pub fn as_t4(self) -> Option<T4> {
1270 match self {
1271 Self::T4(t4) => Some(t4),
1272 _ => None,
1273 }
1274 }
1275
1276 pub fn as_t5(self) -> Option<T5> {
1278 match self {
1279 Self::T5(t5) => Some(t5),
1280 _ => None,
1281 }
1282 }
1283
1284 pub fn as_t6(self) -> Option<T6> {
1286 match self {
1287 Self::T6(t6) => Some(t6),
1288 _ => None,
1289 }
1290 }
1291
1292 pub fn as_t7(self) -> Option<T7> {
1294 match self {
1295 Self::T7(t7) => Some(t7),
1296 _ => None,
1297 }
1298 }
1299
1300 pub fn as_t8(self) -> Option<T8> {
1302 match self {
1303 Self::T8(t8) => Some(t8),
1304 _ => None,
1305 }
1306 }
1307
1308 pub fn map_t1<F, B>(self, f: F) -> Or8<B, T2, T3, T4, T5, T6, T7, T8>
1311 where
1312 F: FnOnce(T1) -> B,
1313 {
1314 match self {
1315 Self::T1(t1) => Or8::<B, T2, T3, T4, T5, T6, T7, T8>::T1(f(t1)),
1316 Self::T2(t2) => Or8::<B, T2, T3, T4, T5, T6, T7, T8>::T2(t2),
1317 Self::T3(t3) => Or8::<B, T2, T3, T4, T5, T6, T7, T8>::T3(t3),
1318 Self::T4(t4) => Or8::<B, T2, T3, T4, T5, T6, T7, T8>::T4(t4),
1319 Self::T5(t5) => Or8::<B, T2, T3, T4, T5, T6, T7, T8>::T5(t5),
1320 Self::T6(t6) => Or8::<B, T2, T3, T4, T5, T6, T7, T8>::T6(t6),
1321 Self::T7(t7) => Or8::<B, T2, T3, T4, T5, T6, T7, T8>::T7(t7),
1322 Self::T8(t8) => Or8::<B, T2, T3, T4, T5, T6, T7, T8>::T8(t8),
1323 }
1324 }
1325
1326 pub fn map_t2<F, B>(self, f: F) -> Or8<T1, B, T3, T4, T5, T6, T7, T8>
1329 where
1330 F: FnOnce(T2) -> B,
1331 {
1332 match self {
1333 Self::T1(t1) => Or8::<T1, B, T3, T4, T5, T6, T7, T8>::T1(t1),
1334 Self::T2(t2) => Or8::<T1, B, T3, T4, T5, T6, T7, T8>::T2(f(t2)),
1335 Self::T3(t3) => Or8::<T1, B, T3, T4, T5, T6, T7, T8>::T3(t3),
1336 Self::T4(t4) => Or8::<T1, B, T3, T4, T5, T6, T7, T8>::T4(t4),
1337 Self::T5(t5) => Or8::<T1, B, T3, T4, T5, T6, T7, T8>::T5(t5),
1338 Self::T6(t6) => Or8::<T1, B, T3, T4, T5, T6, T7, T8>::T6(t6),
1339 Self::T7(t7) => Or8::<T1, B, T3, T4, T5, T6, T7, T8>::T7(t7),
1340 Self::T8(t8) => Or8::<T1, B, T3, T4, T5, T6, T7, T8>::T8(t8),
1341 }
1342 }
1343
1344 pub fn map_t3<F, B>(self, f: F) -> Or8<T1, T2, B, T4, T5, T6, T7, T8>
1347 where
1348 F: FnOnce(T3) -> B,
1349 {
1350 match self {
1351 Self::T1(t1) => Or8::<T1, T2, B, T4, T5, T6, T7, T8>::T1(t1),
1352 Self::T2(t2) => Or8::<T1, T2, B, T4, T5, T6, T7, T8>::T2(t2),
1353 Self::T3(t3) => Or8::<T1, T2, B, T4, T5, T6, T7, T8>::T3(f(t3)),
1354 Self::T4(t4) => Or8::<T1, T2, B, T4, T5, T6, T7, T8>::T4(t4),
1355 Self::T5(t5) => Or8::<T1, T2, B, T4, T5, T6, T7, T8>::T5(t5),
1356 Self::T6(t6) => Or8::<T1, T2, B, T4, T5, T6, T7, T8>::T6(t6),
1357 Self::T7(t7) => Or8::<T1, T2, B, T4, T5, T6, T7, T8>::T7(t7),
1358 Self::T8(t8) => Or8::<T1, T2, B, T4, T5, T6, T7, T8>::T8(t8),
1359 }
1360 }
1361
1362 pub fn map_t4<F, B>(self, f: F) -> Or8<T1, T2, T3, B, T5, T6, T7, T8>
1365 where
1366 F: FnOnce(T4) -> B,
1367 {
1368 match self {
1369 Self::T1(t1) => Or8::<T1, T2, T3, B, T5, T6, T7, T8>::T1(t1),
1370 Self::T2(t2) => Or8::<T1, T2, T3, B, T5, T6, T7, T8>::T2(t2),
1371 Self::T3(t3) => Or8::<T1, T2, T3, B, T5, T6, T7, T8>::T3(t3),
1372 Self::T4(t4) => Or8::<T1, T2, T3, B, T5, T6, T7, T8>::T4(f(t4)),
1373 Self::T5(t5) => Or8::<T1, T2, T3, B, T5, T6, T7, T8>::T5(t5),
1374 Self::T6(t6) => Or8::<T1, T2, T3, B, T5, T6, T7, T8>::T6(t6),
1375 Self::T7(t7) => Or8::<T1, T2, T3, B, T5, T6, T7, T8>::T7(t7),
1376 Self::T8(t8) => Or8::<T1, T2, T3, B, T5, T6, T7, T8>::T8(t8),
1377 }
1378 }
1379
1380 pub fn map_t5<F, B>(self, f: F) -> Or8<T1, T2, T3, T4, B, T6, T7, T8>
1383 where
1384 F: FnOnce(T5) -> B,
1385 {
1386 match self {
1387 Self::T1(t1) => Or8::<T1, T2, T3, T4, B, T6, T7, T8>::T1(t1),
1388 Self::T2(t2) => Or8::<T1, T2, T3, T4, B, T6, T7, T8>::T2(t2),
1389 Self::T3(t3) => Or8::<T1, T2, T3, T4, B, T6, T7, T8>::T3(t3),
1390 Self::T4(t4) => Or8::<T1, T2, T3, T4, B, T6, T7, T8>::T4(t4),
1391 Self::T5(t5) => Or8::<T1, T2, T3, T4, B, T6, T7, T8>::T5(f(t5)),
1392 Self::T6(t6) => Or8::<T1, T2, T3, T4, B, T6, T7, T8>::T6(t6),
1393 Self::T7(t7) => Or8::<T1, T2, T3, T4, B, T6, T7, T8>::T7(t7),
1394 Self::T8(t8) => Or8::<T1, T2, T3, T4, B, T6, T7, T8>::T8(t8),
1395 }
1396 }
1397
1398 pub fn map_t6<F, B>(self, f: F) -> Or8<T1, T2, T3, T4, T5, B, T7, T8>
1401 where
1402 F: FnOnce(T6) -> B,
1403 {
1404 match self {
1405 Self::T1(t1) => Or8::<T1, T2, T3, T4, T5, B, T7, T8>::T1(t1),
1406 Self::T2(t2) => Or8::<T1, T2, T3, T4, T5, B, T7, T8>::T2(t2),
1407 Self::T3(t3) => Or8::<T1, T2, T3, T4, T5, B, T7, T8>::T3(t3),
1408 Self::T4(t4) => Or8::<T1, T2, T3, T4, T5, B, T7, T8>::T4(t4),
1409 Self::T5(t5) => Or8::<T1, T2, T3, T4, T5, B, T7, T8>::T5(t5),
1410 Self::T6(t6) => Or8::<T1, T2, T3, T4, T5, B, T7, T8>::T6(f(t6)),
1411 Self::T7(t7) => Or8::<T1, T2, T3, T4, T5, B, T7, T8>::T7(t7),
1412 Self::T8(t8) => Or8::<T1, T2, T3, T4, T5, B, T7, T8>::T8(t8),
1413 }
1414 }
1415
1416 pub fn map_t7<F, B>(self, f: F) -> Or8<T1, T2, T3, T4, T5, T6, B, T8>
1419 where
1420 F: FnOnce(T7) -> B,
1421 {
1422 match self {
1423 Self::T1(t1) => Or8::<T1, T2, T3, T4, T5, T6, B, T8>::T1(t1),
1424 Self::T2(t2) => Or8::<T1, T2, T3, T4, T5, T6, B, T8>::T2(t2),
1425 Self::T3(t3) => Or8::<T1, T2, T3, T4, T5, T6, B, T8>::T3(t3),
1426 Self::T4(t4) => Or8::<T1, T2, T3, T4, T5, T6, B, T8>::T4(t4),
1427 Self::T5(t5) => Or8::<T1, T2, T3, T4, T5, T6, B, T8>::T5(t5),
1428 Self::T6(t6) => Or8::<T1, T2, T3, T4, T5, T6, B, T8>::T6(t6),
1429 Self::T7(t7) => Or8::<T1, T2, T3, T4, T5, T6, B, T8>::T7(f(t7)),
1430 Self::T8(t8) => Or8::<T1, T2, T3, T4, T5, T6, B, T8>::T8(t8),
1431 }
1432 }
1433
1434 pub fn map_t8<F, B>(self, f: F) -> Or8<T1, T2, T3, T4, T5, T6, T7, B>
1437 where
1438 F: FnOnce(T8) -> B,
1439 {
1440 match self {
1441 Self::T1(t1) => Or8::<T1, T2, T3, T4, T5, T6, T7, B>::T1(t1),
1442 Self::T2(t2) => Or8::<T1, T2, T3, T4, T5, T6, T7, B>::T2(t2),
1443 Self::T3(t3) => Or8::<T1, T2, T3, T4, T5, T6, T7, B>::T3(t3),
1444 Self::T4(t4) => Or8::<T1, T2, T3, T4, T5, T6, T7, B>::T4(t4),
1445 Self::T5(t5) => Or8::<T1, T2, T3, T4, T5, T6, T7, B>::T5(t5),
1446 Self::T6(t6) => Or8::<T1, T2, T3, T4, T5, T6, T7, B>::T6(t6),
1447 Self::T7(t7) => Or8::<T1, T2, T3, T4, T5, T6, T7, B>::T7(t7),
1448 Self::T8(t8) => Or8::<T1, T2, T3, T4, T5, T6, T7, B>::T8(f(t8)),
1449 }
1450 }
1451
1452 pub fn fold<T, F0, F1, F2, F3, F4, F5, F6, F7, F8>(
1455 self,
1456 f1: F1,
1457 f2: F2,
1458 f3: F3,
1459 f4: F4,
1460 f5: F5,
1461 f6: F6,
1462 f7: F7,
1463 f8: F8,
1464 ) -> T
1465 where
1466 F1: FnOnce(T1) -> T,
1467 F2: FnOnce(T2) -> T,
1468 F3: FnOnce(T3) -> T,
1469 F4: FnOnce(T4) -> T,
1470 F5: FnOnce(T5) -> T,
1471 F6: FnOnce(T6) -> T,
1472 F7: FnOnce(T7) -> T,
1473 F8: FnOnce(T8) -> T,
1474 {
1475 match self {
1476 Self::T1(t1) => f1(t1),
1477 Self::T2(t2) => f2(t2),
1478 Self::T3(t3) => f3(t3),
1479 Self::T4(t4) => f4(t4),
1480 Self::T5(t5) => f5(t5),
1481 Self::T6(t6) => f6(t6),
1482 Self::T7(t7) => f7(t7),
1483 Self::T8(t8) => f8(t8),
1484 }
1485 }
1486}
1487
1488impl<T1, T2, T3, T4, T5, T6, T7, T8> Or8<T1, T2, T3, T4, T5, T6, T7, T8>
1492where
1493 T1: 'static,
1494 T2: 'static,
1495 T3: 'static,
1496 T4: 'static,
1497 T5: 'static,
1498 T6: 'static,
1499 T7: 'static,
1500 T8: 'static,
1501{
1502 pub fn is_type<T: 'static>(&self) -> bool {
1503 match self {
1504 Self::T1(_) => TypeId::of::<T>() == TypeId::of::<T1>(),
1505 Self::T2(_) => TypeId::of::<T>() == TypeId::of::<T2>(),
1506 Self::T3(_) => TypeId::of::<T>() == TypeId::of::<T3>(),
1507 Self::T4(_) => TypeId::of::<T>() == TypeId::of::<T4>(),
1508 Self::T5(_) => TypeId::of::<T>() == TypeId::of::<T5>(),
1509 Self::T6(_) => TypeId::of::<T>() == TypeId::of::<T6>(),
1510 Self::T7(_) => TypeId::of::<T>() == TypeId::of::<T7>(),
1511 Self::T8(_) => TypeId::of::<T>() == TypeId::of::<T8>(),
1512 }
1513 }
1514}
1515
1516pub enum Or9<T1, T2, T3, T4, T5, T6, T7, T8, T9> {
1518 T1(T1),
1519 T2(T2),
1520 T3(T3),
1521 T4(T4),
1522 T5(T5),
1523 T6(T6),
1524 T7(T7),
1525 T8(T8),
1526 T9(T9),
1527}
1528
1529impl<T1, T2, T3, T4, T5, T6, T7, T8, T9> Or9<T1, T2, T3, T4, T5, T6, T7, T8, T9> {
1530 pub fn is_t1(&self) -> bool {
1532 match self {
1533 Self::T1(_) => true,
1534 _ => false,
1535 }
1536 }
1537
1538 pub fn is_t2(&self) -> bool {
1540 match self {
1541 Self::T2(_) => true,
1542 _ => false,
1543 }
1544 }
1545
1546 pub fn is_t3(&self) -> bool {
1548 match self {
1549 Self::T3(_) => true,
1550 _ => false,
1551 }
1552 }
1553
1554 pub fn is_t4(&self) -> bool {
1556 match self {
1557 Self::T4(_) => true,
1558 _ => false,
1559 }
1560 }
1561
1562 pub fn is_t5(&self) -> bool {
1564 match self {
1565 Self::T5(_) => true,
1566 _ => false,
1567 }
1568 }
1569
1570 pub fn is_t6(&self) -> bool {
1572 match self {
1573 Self::T6(_) => true,
1574 _ => false,
1575 }
1576 }
1577
1578 pub fn is_t7(&self) -> bool {
1580 match self {
1581 Self::T7(_) => true,
1582 _ => false,
1583 }
1584 }
1585
1586 pub fn is_t8(&self) -> bool {
1588 match self {
1589 Self::T8(_) => true,
1590 _ => false,
1591 }
1592 }
1593
1594 pub fn is_t9(&self) -> bool {
1596 match self {
1597 Self::T9(_) => true,
1598 _ => false,
1599 }
1600 }
1601
1602 pub fn as_t1(self) -> Option<T1> {
1604 match self {
1605 Self::T1(t1) => Some(t1),
1606 _ => None,
1607 }
1608 }
1609
1610 pub fn as_t2(self) -> Option<T2> {
1612 match self {
1613 Self::T2(t2) => Some(t2),
1614 _ => None,
1615 }
1616 }
1617
1618 pub fn as_t3(self) -> Option<T3> {
1620 match self {
1621 Self::T3(t3) => Some(t3),
1622 _ => None,
1623 }
1624 }
1625
1626 pub fn as_t4(self) -> Option<T4> {
1628 match self {
1629 Self::T4(t4) => Some(t4),
1630 _ => None,
1631 }
1632 }
1633
1634 pub fn as_t5(self) -> Option<T5> {
1636 match self {
1637 Self::T5(t5) => Some(t5),
1638 _ => None,
1639 }
1640 }
1641
1642 pub fn as_t6(self) -> Option<T6> {
1644 match self {
1645 Self::T6(t6) => Some(t6),
1646 _ => None,
1647 }
1648 }
1649
1650 pub fn as_t7(self) -> Option<T7> {
1652 match self {
1653 Self::T7(t7) => Some(t7),
1654 _ => None,
1655 }
1656 }
1657
1658 pub fn as_t8(self) -> Option<T8> {
1660 match self {
1661 Self::T8(t8) => Some(t8),
1662 _ => None,
1663 }
1664 }
1665
1666 pub fn as_t9(self) -> Option<T9> {
1668 match self {
1669 Self::T9(t9) => Some(t9),
1670 _ => None,
1671 }
1672 }
1673
1674 pub fn map_t1<F, B>(self, f: F) -> Or9<B, T2, T3, T4, T5, T6, T7, T8, T9>
1677 where
1678 F: FnOnce(T1) -> B,
1679 {
1680 match self {
1681 Self::T1(t1) => Or9::<B, T2, T3, T4, T5, T6, T7, T8, T9>::T1(f(t1)),
1682 Self::T2(t2) => Or9::<B, T2, T3, T4, T5, T6, T7, T8, T9>::T2(t2),
1683 Self::T3(t3) => Or9::<B, T2, T3, T4, T5, T6, T7, T8, T9>::T3(t3),
1684 Self::T4(t4) => Or9::<B, T2, T3, T4, T5, T6, T7, T8, T9>::T4(t4),
1685 Self::T5(t5) => Or9::<B, T2, T3, T4, T5, T6, T7, T8, T9>::T5(t5),
1686 Self::T6(t6) => Or9::<B, T2, T3, T4, T5, T6, T7, T8, T9>::T6(t6),
1687 Self::T7(t7) => Or9::<B, T2, T3, T4, T5, T6, T7, T8, T9>::T7(t7),
1688 Self::T8(t8) => Or9::<B, T2, T3, T4, T5, T6, T7, T8, T9>::T8(t8),
1689 Self::T9(t9) => Or9::<B, T2, T3, T4, T5, T6, T7, T8, T9>::T9(t9),
1690 }
1691 }
1692
1693 pub fn map_t2<F, B>(self, f: F) -> Or9<T1, B, T3, T4, T5, T6, T7, T8, T9>
1696 where
1697 F: FnOnce(T2) -> B,
1698 {
1699 match self {
1700 Self::T1(t1) => Or9::<T1, B, T3, T4, T5, T6, T7, T8, T9>::T1(t1),
1701 Self::T2(t2) => Or9::<T1, B, T3, T4, T5, T6, T7, T8, T9>::T2(f(t2)),
1702 Self::T3(t3) => Or9::<T1, B, T3, T4, T5, T6, T7, T8, T9>::T3(t3),
1703 Self::T4(t4) => Or9::<T1, B, T3, T4, T5, T6, T7, T8, T9>::T4(t4),
1704 Self::T5(t5) => Or9::<T1, B, T3, T4, T5, T6, T7, T8, T9>::T5(t5),
1705 Self::T6(t6) => Or9::<T1, B, T3, T4, T5, T6, T7, T8, T9>::T6(t6),
1706 Self::T7(t7) => Or9::<T1, B, T3, T4, T5, T6, T7, T8, T9>::T7(t7),
1707 Self::T8(t8) => Or9::<T1, B, T3, T4, T5, T6, T7, T8, T9>::T8(t8),
1708 Self::T9(t9) => Or9::<T1, B, T3, T4, T5, T6, T7, T8, T9>::T9(t9),
1709 }
1710 }
1711
1712 pub fn map_t3<F, B>(self, f: F) -> Or9<T1, T2, B, T4, T5, T6, T7, T8, T9>
1715 where
1716 F: FnOnce(T3) -> B,
1717 {
1718 match self {
1719 Self::T1(t1) => Or9::<T1, T2, B, T4, T5, T6, T7, T8, T9>::T1(t1),
1720 Self::T2(t2) => Or9::<T1, T2, B, T4, T5, T6, T7, T8, T9>::T2(t2),
1721 Self::T3(t3) => Or9::<T1, T2, B, T4, T5, T6, T7, T8, T9>::T3(f(t3)),
1722 Self::T4(t4) => Or9::<T1, T2, B, T4, T5, T6, T7, T8, T9>::T4(t4),
1723 Self::T5(t5) => Or9::<T1, T2, B, T4, T5, T6, T7, T8, T9>::T5(t5),
1724 Self::T6(t6) => Or9::<T1, T2, B, T4, T5, T6, T7, T8, T9>::T6(t6),
1725 Self::T7(t7) => Or9::<T1, T2, B, T4, T5, T6, T7, T8, T9>::T7(t7),
1726 Self::T8(t8) => Or9::<T1, T2, B, T4, T5, T6, T7, T8, T9>::T8(t8),
1727 Self::T9(t9) => Or9::<T1, T2, B, T4, T5, T6, T7, T8, T9>::T9(t9),
1728 }
1729 }
1730
1731 pub fn map_t4<F, B>(self, f: F) -> Or9<T1, T2, T3, B, T5, T6, T7, T8, T9>
1734 where
1735 F: FnOnce(T4) -> B,
1736 {
1737 match self {
1738 Self::T1(t1) => Or9::<T1, T2, T3, B, T5, T6, T7, T8, T9>::T1(t1),
1739 Self::T2(t2) => Or9::<T1, T2, T3, B, T5, T6, T7, T8, T9>::T2(t2),
1740 Self::T3(t3) => Or9::<T1, T2, T3, B, T5, T6, T7, T8, T9>::T3(t3),
1741 Self::T4(t4) => Or9::<T1, T2, T3, B, T5, T6, T7, T8, T9>::T4(f(t4)),
1742 Self::T5(t5) => Or9::<T1, T2, T3, B, T5, T6, T7, T8, T9>::T5(t5),
1743 Self::T6(t6) => Or9::<T1, T2, T3, B, T5, T6, T7, T8, T9>::T6(t6),
1744 Self::T7(t7) => Or9::<T1, T2, T3, B, T5, T6, T7, T8, T9>::T7(t7),
1745 Self::T8(t8) => Or9::<T1, T2, T3, B, T5, T6, T7, T8, T9>::T8(t8),
1746 Self::T9(t9) => Or9::<T1, T2, T3, B, T5, T6, T7, T8, T9>::T9(t9),
1747 }
1748 }
1749
1750 pub fn map_t5<F, B>(self, f: F) -> Or9<T1, T2, T3, T4, B, T6, T7, T8, T9>
1753 where
1754 F: FnOnce(T5) -> B,
1755 {
1756 match self {
1757 Self::T1(t1) => Or9::<T1, T2, T3, T4, B, T6, T7, T8, T9>::T1(t1),
1758 Self::T2(t2) => Or9::<T1, T2, T3, T4, B, T6, T7, T8, T9>::T2(t2),
1759 Self::T3(t3) => Or9::<T1, T2, T3, T4, B, T6, T7, T8, T9>::T3(t3),
1760 Self::T4(t4) => Or9::<T1, T2, T3, T4, B, T6, T7, T8, T9>::T4(t4),
1761 Self::T5(t5) => Or9::<T1, T2, T3, T4, B, T6, T7, T8, T9>::T5(f(t5)),
1762 Self::T6(t6) => Or9::<T1, T2, T3, T4, B, T6, T7, T8, T9>::T6(t6),
1763 Self::T7(t7) => Or9::<T1, T2, T3, T4, B, T6, T7, T8, T9>::T7(t7),
1764 Self::T8(t8) => Or9::<T1, T2, T3, T4, B, T6, T7, T8, T9>::T8(t8),
1765 Self::T9(t9) => Or9::<T1, T2, T3, T4, B, T6, T7, T8, T9>::T9(t9),
1766 }
1767 }
1768
1769 pub fn map_t6<F, B>(self, f: F) -> Or9<T1, T2, T3, T4, T5, B, T7, T8, T9>
1772 where
1773 F: FnOnce(T6) -> B,
1774 {
1775 match self {
1776 Self::T1(t1) => Or9::<T1, T2, T3, T4, T5, B, T7, T8, T9>::T1(t1),
1777 Self::T2(t2) => Or9::<T1, T2, T3, T4, T5, B, T7, T8, T9>::T2(t2),
1778 Self::T3(t3) => Or9::<T1, T2, T3, T4, T5, B, T7, T8, T9>::T3(t3),
1779 Self::T4(t4) => Or9::<T1, T2, T3, T4, T5, B, T7, T8, T9>::T4(t4),
1780 Self::T5(t5) => Or9::<T1, T2, T3, T4, T5, B, T7, T8, T9>::T5(t5),
1781 Self::T6(t6) => Or9::<T1, T2, T3, T4, T5, B, T7, T8, T9>::T6(f(t6)),
1782 Self::T7(t7) => Or9::<T1, T2, T3, T4, T5, B, T7, T8, T9>::T7(t7),
1783 Self::T8(t8) => Or9::<T1, T2, T3, T4, T5, B, T7, T8, T9>::T8(t8),
1784 Self::T9(t9) => Or9::<T1, T2, T3, T4, T5, B, T7, T8, T9>::T9(t9),
1785 }
1786 }
1787
1788 pub fn map_t7<F, B>(self, f: F) -> Or9<T1, T2, T3, T4, T5, T6, B, T8, T9>
1791 where
1792 F: FnOnce(T7) -> B,
1793 {
1794 match self {
1795 Self::T1(t1) => Or9::<T1, T2, T3, T4, T5, T6, B, T8, T9>::T1(t1),
1796 Self::T2(t2) => Or9::<T1, T2, T3, T4, T5, T6, B, T8, T9>::T2(t2),
1797 Self::T3(t3) => Or9::<T1, T2, T3, T4, T5, T6, B, T8, T9>::T3(t3),
1798 Self::T4(t4) => Or9::<T1, T2, T3, T4, T5, T6, B, T8, T9>::T4(t4),
1799 Self::T5(t5) => Or9::<T1, T2, T3, T4, T5, T6, B, T8, T9>::T5(t5),
1800 Self::T6(t6) => Or9::<T1, T2, T3, T4, T5, T6, B, T8, T9>::T6(t6),
1801 Self::T7(t7) => Or9::<T1, T2, T3, T4, T5, T6, B, T8, T9>::T7(f(t7)),
1802 Self::T8(t8) => Or9::<T1, T2, T3, T4, T5, T6, B, T8, T9>::T8(t8),
1803 Self::T9(t9) => Or9::<T1, T2, T3, T4, T5, T6, B, T8, T9>::T9(t9),
1804 }
1805 }
1806
1807 pub fn map_t8<F, B>(self, f: F) -> Or9<T1, T2, T3, T4, T5, T6, T7, B, T9>
1810 where
1811 F: FnOnce(T8) -> B,
1812 {
1813 match self {
1814 Self::T1(t1) => Or9::<T1, T2, T3, T4, T5, T6, T7, B, T9>::T1(t1),
1815 Self::T2(t2) => Or9::<T1, T2, T3, T4, T5, T6, T7, B, T9>::T2(t2),
1816 Self::T3(t3) => Or9::<T1, T2, T3, T4, T5, T6, T7, B, T9>::T3(t3),
1817 Self::T4(t4) => Or9::<T1, T2, T3, T4, T5, T6, T7, B, T9>::T4(t4),
1818 Self::T5(t5) => Or9::<T1, T2, T3, T4, T5, T6, T7, B, T9>::T5(t5),
1819 Self::T6(t6) => Or9::<T1, T2, T3, T4, T5, T6, T7, B, T9>::T6(t6),
1820 Self::T7(t7) => Or9::<T1, T2, T3, T4, T5, T6, T7, B, T9>::T7(t7),
1821 Self::T8(t8) => Or9::<T1, T2, T3, T4, T5, T6, T7, B, T9>::T8(f(t8)),
1822 Self::T9(t9) => Or9::<T1, T2, T3, T4, T5, T6, T7, B, T9>::T9(t9),
1823 }
1824 }
1825
1826 pub fn map_t9<F, B>(self, f: F) -> Or9<T1, T2, T3, T4, T5, T6, T7, T8, B>
1829 where
1830 F: FnOnce(T9) -> B,
1831 {
1832 match self {
1833 Self::T1(t1) => Or9::<T1, T2, T3, T4, T5, T6, T7, T8, B>::T1(t1),
1834 Self::T2(t2) => Or9::<T1, T2, T3, T4, T5, T6, T7, T8, B>::T2(t2),
1835 Self::T3(t3) => Or9::<T1, T2, T3, T4, T5, T6, T7, T8, B>::T3(t3),
1836 Self::T4(t4) => Or9::<T1, T2, T3, T4, T5, T6, T7, T8, B>::T4(t4),
1837 Self::T5(t5) => Or9::<T1, T2, T3, T4, T5, T6, T7, T8, B>::T5(t5),
1838 Self::T6(t6) => Or9::<T1, T2, T3, T4, T5, T6, T7, T8, B>::T6(t6),
1839 Self::T7(t7) => Or9::<T1, T2, T3, T4, T5, T6, T7, T8, B>::T7(t7),
1840 Self::T8(t8) => Or9::<T1, T2, T3, T4, T5, T6, T7, T8, B>::T8(t8),
1841 Self::T9(t9) => Or9::<T1, T2, T3, T4, T5, T6, T7, T8, B>::T9(f(t9)),
1842 }
1843 }
1844
1845 pub fn fold<T, F0, F1, F2, F3, F4, F5, F6, F7, F8, F9>(
1848 self,
1849 f1: F1,
1850 f2: F2,
1851 f3: F3,
1852 f4: F4,
1853 f5: F5,
1854 f6: F6,
1855 f7: F7,
1856 f8: F8,
1857 f9: F9,
1858 ) -> T
1859 where
1860 F1: FnOnce(T1) -> T,
1861 F2: FnOnce(T2) -> T,
1862 F3: FnOnce(T3) -> T,
1863 F4: FnOnce(T4) -> T,
1864 F5: FnOnce(T5) -> T,
1865 F6: FnOnce(T6) -> T,
1866 F7: FnOnce(T7) -> T,
1867 F8: FnOnce(T8) -> T,
1868 F9: FnOnce(T9) -> T,
1869 {
1870 match self {
1871 Self::T1(t1) => f1(t1),
1872 Self::T2(t2) => f2(t2),
1873 Self::T3(t3) => f3(t3),
1874 Self::T4(t4) => f4(t4),
1875 Self::T5(t5) => f5(t5),
1876 Self::T6(t6) => f6(t6),
1877 Self::T7(t7) => f7(t7),
1878 Self::T8(t8) => f8(t8),
1879 Self::T9(t9) => f9(t9),
1880 }
1881 }
1882}
1883
1884impl<T1, T2, T3, T4, T5, T6, T7, T8, T9> Or9<T1, T2, T3, T4, T5, T6, T7, T8, T9>
1888where
1889 T1: 'static,
1890 T2: 'static,
1891 T3: 'static,
1892 T4: 'static,
1893 T5: 'static,
1894 T6: 'static,
1895 T7: 'static,
1896 T8: 'static,
1897 T9: 'static,
1898{
1899 pub fn is_type<T: 'static>(&self) -> bool {
1900 match self {
1901 Self::T1(_) => TypeId::of::<T>() == TypeId::of::<T1>(),
1902 Self::T2(_) => TypeId::of::<T>() == TypeId::of::<T2>(),
1903 Self::T3(_) => TypeId::of::<T>() == TypeId::of::<T3>(),
1904 Self::T4(_) => TypeId::of::<T>() == TypeId::of::<T4>(),
1905 Self::T5(_) => TypeId::of::<T>() == TypeId::of::<T5>(),
1906 Self::T6(_) => TypeId::of::<T>() == TypeId::of::<T6>(),
1907 Self::T7(_) => TypeId::of::<T>() == TypeId::of::<T7>(),
1908 Self::T8(_) => TypeId::of::<T>() == TypeId::of::<T8>(),
1909 Self::T9(_) => TypeId::of::<T>() == TypeId::of::<T9>(),
1910 }
1911 }
1912}