Skip to content

Commit 7649860

Browse files
committed
libcore: result::unwrap should use moves
1 parent afeaf7d commit 7649860

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/libcore/result.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,10 @@ fn iter_vec2<S,T,U:copy>(ss: &[S], ts: &[T],
341341
}
342342

343343
/// Unwraps a result, assuming it is an `ok(T)`
344-
fn unwrap<T, U>(-res: Result<T, U>) -> T {
345-
unsafe {
346-
let addr = match res {
347-
Ok(x) => ptr::addr_of(x),
348-
Err(_) => fail ~"error result"
349-
};
350-
let liberated_value = unsafe::reinterpret_cast(*addr);
351-
unsafe::forget(res);
352-
return liberated_value;
344+
fn unwrap<T, U>(+res: Result<T, U>) -> T {
345+
match move res {
346+
Ok(move t) => t,
347+
Err(_) => fail ~"unwrap called on an err result"
353348
}
354349
}
355350

0 commit comments

Comments
 (0)