@@ -26,49 +26,49 @@ impl<A, B> EitherOrBoth<A, B> {
26
26
27
27
/// If Left, return true otherwise, return false.
28
28
/// Exclusive version of [`has_left`].
29
- pub fn is_just_left ( & self ) -> bool {
29
+ pub fn is_just_left ( & self ) -> bool {
30
30
match * self {
31
31
Left ( _) => true ,
32
- _ => false
32
+ _ => false ,
33
33
}
34
34
}
35
35
36
36
/// If Right, return true otherwise, return false.
37
37
/// Exclusive version of [`has_right`].
38
- pub fn is_just_right ( & self ) -> bool {
38
+ pub fn is_just_right ( & self ) -> bool {
39
39
match * self {
40
40
Right ( _) => true ,
41
- _ => false
41
+ _ => false ,
42
42
}
43
43
}
44
44
45
45
/// If Right, return true otherwise, return false.
46
46
/// Equivalent to `self.as_ref().both().is_some()`.
47
- pub fn is_just_both ( & self ) -> bool {
47
+ pub fn is_just_both ( & self ) -> bool {
48
48
self . as_ref ( ) . both ( ) . is_some ( )
49
49
}
50
50
51
51
/// If `Left`, or `Both`, return `Some` with the left value, otherwise, return `None`.
52
52
pub fn left ( self ) -> Option < A > {
53
53
match self {
54
54
Left ( left) | Both ( left, _) => Some ( left) ,
55
- _ => None
55
+ _ => None ,
56
56
}
57
57
}
58
58
59
59
/// If `Right`, or `Both`, return `Some` with the right value, otherwise, return `None`.
60
60
pub fn right ( self ) -> Option < B > {
61
61
match self {
62
62
Right ( right) | Both ( _, right) => Some ( right) ,
63
- _ => None
63
+ _ => None ,
64
64
}
65
65
}
66
66
67
67
/// If Both, return `Some` tuple containing left and right.
68
68
pub fn both ( self ) -> Option < ( A , B ) > {
69
69
match self {
70
70
Both ( a, b) => Some ( ( a, b) ) ,
71
- _ => None
71
+ _ => None ,
72
72
}
73
73
}
74
74
@@ -93,7 +93,10 @@ impl<A, B> EitherOrBoth<A, B> {
93
93
/// Convert `EitherOrBoth<A, B>` to `EitherOrBoth<B, A>`.
94
94
pub fn flip ( self ) -> EitherOrBoth < B , A > {
95
95
match self {
96
- Left ( a) => Right ( a) , Right ( b) => Left ( b) , Both ( a, b) => Both ( b, a) , }
96
+ Left ( a) => Right ( a) ,
97
+ Right ( b) => Left ( b) ,
98
+ Both ( a, b) => Both ( b, a) ,
99
+ }
97
100
}
98
101
99
102
/// Apply the function `f` on the value `a` in `Left(a)` or `Both(a, b)` variants. If it is
@@ -104,7 +107,9 @@ impl<A, B> EitherOrBoth<A, B> {
104
107
{
105
108
match self {
106
109
Both ( a, b) => Both ( f ( a) , b) ,
107
- Left ( a) => Left ( f ( a) ) , Right ( b) => Right ( b) , }
110
+ Left ( a) => Left ( f ( a) ) ,
111
+ Right ( b) => Right ( b) ,
112
+ }
108
113
}
109
114
110
115
/// Apply the function `f` on the value `b` in `Right(b)` or `Both(a, b)` variants.
0 commit comments