diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 63c846b25eca5..12e6e8430562a 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -634,16 +634,12 @@ impl Option { #[inline] #[unstable(feature = "option_filter", issue = "45860")] pub fn filter 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`.