Skip to content

Commit

Permalink
auto merge of #12931 : aochagavia/rust/option-take_unwrap, r=cmr
Browse files Browse the repository at this point in the history
Using pattern matching instead of is_some + unwrap
  • Loading branch information
bors committed Mar 16, 2014
2 parents 7647849 + ea8da6e commit 9e89ffc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libstd/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,10 @@ impl<T> Option<T> {
/// Fails if the value equals `None`.
#[inline]
pub fn take_unwrap(&mut self) -> T {
if self.is_none() {
fail!("called `Option::take_unwrap()` on a `None` value")
match self.take() {
Some(x) => x,
None => fail!("called `Option::take_unwrap()` on a `None` value")
}
self.take().unwrap()
}

/// Gets an immutable reference to the value inside an option.
Expand Down

0 comments on commit 9e89ffc

Please sign in to comment.