Skip to content

Commit 5c6be13

Browse files
committed
libcore: add result::unwrap_err.
1 parent 7649860 commit 5c6be13

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libcore/result.rs

+8
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,14 @@ fn unwrap<T, U>(+res: Result<T, U>) -> T {
348348
}
349349
}
350350

351+
/// Unwraps a result, assuming it is an `err(U)`
352+
fn unwrap_err<T, U>(+res: Result<T, U>) -> U {
353+
match move res {
354+
Err(move u) => u,
355+
Ok(_) => fail ~"unwrap called on an ok result"
356+
}
357+
}
358+
351359
impl<T:Eq,U:Eq> Result<T,U> : Eq {
352360
pure fn eq(&&other: Result<T,U>) -> bool {
353361
match self {

0 commit comments

Comments
 (0)