diff options
| author | bors <bors@rust-lang.org> | 2014-03-16 14:11:26 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-03-16 14:11:26 -0700 |
| commit | 9e89ffc60e4a72dd0e6e9b1930111235b18e595e (patch) | |
| tree | fc9e129aa2d8b66d54fb8389c3c58fb550e0f53a /src/libstd | |
| parent | 76478492ef087ad0fcdcc873940a048507445c7a (diff) | |
| parent | ea8da6ed9743eb6cf047a1080c711bdceec93375 (diff) | |
| download | rust-9e89ffc60e4a72dd0e6e9b1930111235b18e595e.tar.gz rust-9e89ffc60e4a72dd0e6e9b1930111235b18e595e.zip | |
auto merge of #12931 : aochagavia/rust/option-take_unwrap, r=cmr
Using pattern matching instead of is_some + unwrap
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/option.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libstd/option.rs b/src/libstd/option.rs index b70c8e17259..e4d843d8882 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -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. |
