We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 574dff9 + abff092 commit 3604737Copy full SHA for 3604737
src/libcore/option.rs
@@ -634,16 +634,12 @@ impl<T> Option<T> {
634
#[inline]
635
#[unstable(feature = "option_filter", issue = "45860")]
636
pub fn filter<P: FnOnce(&T) -> bool>(self, predicate: P) -> Self {
637
- match self {
638
- Some(x) => {
639
- if predicate(&x) {
640
- Some(x)
641
- } else {
642
- None
643
- }
+ if let Some(x) = self {
+ if predicate(&x) {
+ return Some(x)
644
}
645
- None => None,
646
+ None
647
648
649
/// Returns the option if it contains a value, otherwise returns `optb`.
0 commit comments