@@ -35,8 +35,8 @@ pub enum Either<T, U> {
35
35
pub fn either < T , U , V > ( f_left : & fn ( & T ) -> V ,
36
36
f_right : & fn ( & U ) -> V , value : & Either < T , U > ) -> V {
37
37
match * value {
38
- Left ( ref l) => f_left ( l) ,
39
- Right ( ref r) => f_right ( r)
38
+ Left ( ref l) => f_left ( l) ,
39
+ Right ( ref r) => f_right ( r)
40
40
}
41
41
}
42
42
@@ -73,8 +73,8 @@ pub fn partition<T, U>(eithers: ~[Either<T, U>]) -> (~[T], ~[U]) {
73
73
let mut rights: ~[ U ] = ~[ ] ;
74
74
do vec:: consume ( eithers) |_i, elt| {
75
75
match elt {
76
- Left ( l) => lefts. push ( l) ,
77
- Right ( r) => rights. push ( r)
76
+ Left ( l) => lefts. push ( l) ,
77
+ Right ( r) => rights. push ( r)
78
78
}
79
79
}
80
80
return ( lefts, rights) ;
@@ -84,8 +84,8 @@ pub fn partition<T, U>(eithers: ~[Either<T, U>]) -> (~[T], ~[U]) {
84
84
#[ inline( always) ]
85
85
pub fn flip < T , U > ( eith : Either < T , U > ) -> Either < U , T > {
86
86
match eith {
87
- Right ( r) => Left ( r) ,
88
- Left ( l) => Right ( l)
87
+ Right ( r) => Left ( r) ,
88
+ Left ( l) => Right ( l)
89
89
}
90
90
}
91
91
@@ -96,21 +96,27 @@ pub fn flip<T, U>(eith: Either<T, U>) -> Either<U, T> {
96
96
#[ inline( always) ]
97
97
pub fn to_result < T , U > ( eith : Either < T , U > ) -> Result < U , T > {
98
98
match eith {
99
- Right ( r) => result:: Ok ( r) ,
100
- Left ( l) => result:: Err ( l)
99
+ Right ( r) => result:: Ok ( r) ,
100
+ Left ( l) => result:: Err ( l)
101
101
}
102
102
}
103
103
104
104
/// Checks whether the given value is a left
105
105
#[ inline( always) ]
106
106
pub fn is_left < T , U > ( eith : & Either < T , U > ) -> bool {
107
- match * eith { Left ( _) => true , _ => false }
107
+ match * eith {
108
+ Left ( _) => true ,
109
+ _ => false
110
+ }
108
111
}
109
112
110
113
/// Checks whether the given value is a right
111
114
#[ inline( always) ]
112
115
pub fn is_right < T , U > ( eith : & Either < T , U > ) -> bool {
113
- match * eith { Right ( _) => true , _ => false }
116
+ match * eith {
117
+ Right ( _) => true ,
118
+ _ => false
119
+ }
114
120
}
115
121
116
122
/// Retrieves the value in the left branch. Fails if the either is Right.
0 commit comments