Skip to content

Commit 2fe451c

Browse files
committed
Fix patterns in either
1 parent d9a06be commit 2fe451c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/libcore/either.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ fn partition<T: Copy, U: Copy>(eithers: &[Either<T, U>])
6868
let mut rights: ~[U] = ~[];
6969
for vec::each(eithers) |elt| {
7070
match *elt {
71-
Left(l) => lefts.push(l),
72-
Right(r) => rights.push(r)
71+
Left(copy l) => lefts.push(l),
72+
Right(copy r) => rights.push(r)
7373
}
7474
}
7575
return {lefts: move lefts, rights: move rights};
@@ -79,8 +79,8 @@ pure fn flip<T: Copy, U: Copy>(eith: &Either<T, U>) -> Either<U, T> {
7979
//! Flips between left and right of a given either
8080
8181
match *eith {
82-
Right(r) => Left(r),
83-
Left(l) => Right(l)
82+
Right(copy r) => Left(r),
83+
Left(copy l) => Right(l)
8484
}
8585
}
8686

@@ -93,8 +93,8 @@ pure fn to_result<T: Copy, U: Copy>(eith: &Either<T, U>) -> Result<U, T> {
9393
*/
9494

9595
match *eith {
96-
Right(r) => result::Ok(r),
97-
Left(l) => result::Err(l)
96+
Right(copy r) => result::Ok(r),
97+
Left(copy l) => result::Err(l)
9898
}
9999
}
100100

@@ -129,16 +129,16 @@ pure fn unwrap_right<T,U>(+eith: Either<T,U>) -> U {
129129
impl<T:Eq,U:Eq> Either<T,U> : Eq {
130130
pure fn eq(other: &Either<T,U>) -> bool {
131131
match self {
132-
Left(a) => {
132+
Left(ref a) => {
133133
match (*other) {
134-
Left(ref b) => a.eq(b),
134+
Left(ref b) => (*a).eq(b),
135135
Right(_) => false
136136
}
137137
}
138-
Right(a) => {
138+
Right(ref a) => {
139139
match (*other) {
140140
Left(_) => false,
141-
Right(ref b) => a.eq(b)
141+
Right(ref b) => (*a).eq(b)
142142
}
143143
}
144144
}

0 commit comments

Comments
 (0)