either_both/
either_interop.rs1use super::*;
2use either::Either as Other;
3impl<L, R> From<Other<L, R>> for Either<L, R> {
4 fn from(value: Other<L, R>) -> Self {
16 match value {
17 Other::Left(l) => Self::Left(l),
18 Other::Right(r) => Self::Right(r),
19 }
20 }
21}
22
23impl<L, R> From<Other<Other<L, R>, (L, R)>> for Either<L, R> {
24 fn from(value: Other<Other<L, R>, (L, R)>) -> Self {
25 match value {
26 Other::Left(Other::Left(l)) => Self::Left(l),
27 Other::Left(Other::Right(r)) => Self::Right(r),
28 Other::Right((l, r)) => Self::Both(l, r),
29 }
30 }
31}
32
33impl<L, R> From<Other<(L, R), Other<L, R>>> for Either<L, R> {
34 fn from(value: Other<(L, R), Other<L, R>>) -> Self {
35 match value {
36 Other::Left((l, r)) => Self::Both(l, r),
37 Other::Right(Other::Left(l)) => Self::Left(l),
38 Other::Right(Other::Right(r)) => Self::Right(r),
39 }
40 }
41}
42
43impl<L, R> From<Either<L, R>> for Other<Other<L, R>, (L, R)> {
44 fn from(value: Either<L, R>) -> Self {
45 match value {
46 Either::Left(l) => Self::Left(Other::Left(l)),
47 Either::Right(r) => Self::Left(Other::Right(r)),
48 Either::Both(l, r) => Self::Right((l, r)),
49 }
50 }
51}
52
53impl<L, R> From<Either<L, R>> for Other<(L, R), Other<L, R>> {
54 fn from(value: Either<L, R>) -> Self {
55 match value {
56 Either::Left(l) => Self::Right(Other::Left(l)),
57 Either::Right(r) => Self::Right(Other::Right(r)),
58 Either::Both(l, r) => Self::Left((l, r)),
59 }
60 }
61}