diff options
| author | bors <bors@rust-lang.org> | 2017-11-13 09:13:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-11-13 09:13:00 +0000 |
| commit | e312c8a8c3ecd7fead1e8a6cc591360dc73c9e79 (patch) | |
| tree | f89bad69d8c6b8ca6bbddb12c16ab8d9adf9e2b7 /src/libcore | |
| parent | c8c1424bf44d2dfa5b18dd2a85ee5106919c709d (diff) | |
| parent | 48d2627c38e014f5372d1a642bc21e5506fe83f3 (diff) | |
| download | rust-e312c8a8c3ecd7fead1e8a6cc591360dc73c9e79.tar.gz rust-e312c8a8c3ecd7fead1e8a6cc591360dc73c9e79.zip | |
Auto merge of #45956 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests - Successful merges: #45828, #45892, #45893, #45914, #45917, #45927, #45933, #45952, #45954 - Failed merges:
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/option.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 63c846b25ec..12e6e843056 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -634,16 +634,12 @@ impl<T> Option<T> { #[inline] #[unstable(feature = "option_filter", issue = "45860")] pub fn filter<P: FnOnce(&T) -> bool>(self, predicate: P) -> Self { - match self { - Some(x) => { - if predicate(&x) { - Some(x) - } else { - None - } + if let Some(x) = self { + if predicate(&x) { + return Some(x) } - None => None, } + None } /// Returns the option if it contains a value, otherwise returns `optb`. |
