Skip to content

Commit

Permalink
libcore: result::unwrap should use moves
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed Aug 31, 2012
1 parent afeaf7d commit 7649860
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,10 @@ fn iter_vec2<S,T,U:copy>(ss: &[S], ts: &[T],
}

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

Expand Down

0 comments on commit 7649860

Please sign in to comment.