Skip to content

Commit 81e1233

Browse files
committed
---
yaml --- r: 23486 b: refs/heads/master c: 6277046 h: refs/heads/master v: v3
1 parent bf061b8 commit 81e1233

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 4cfb92f4598a6571523bce8b72188df559e2a2b3
2+
refs/heads/master: 6277046fa0a5c119885ba33bcb6ac2f4fba0228f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/either.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,22 @@ pure fn is_right<T, U>(eith: &Either<T, U>) -> bool {
109109
match *eith { Right(_) => true, _ => false }
110110
}
111111

112+
pure fn unwrap_left<T,U>(+eith: Either<T,U>) -> T {
113+
//! Retrieves the value in the left branch. Fails if the either is Right.
114+
115+
match move eith {
116+
Left(move x) => x, Right(_) => fail ~"either::unwrap_left Right"
117+
}
118+
}
119+
120+
pure fn unwrap_right<T,U>(+eith: Either<T,U>) -> U {
121+
//! Retrieves the value in the right branch. Fails if the either is Left.
122+
123+
match move eith {
124+
Right(move x) => x, Left(_) => fail ~"either::unwrap_right Left"
125+
}
126+
}
127+
112128
#[test]
113129
fn test_either_left() {
114130
let val = Left(10);

0 commit comments

Comments
 (0)