mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 13:05:18 +03:00
Rollup merge of #49575 - tmccombs:option-filter-stabilize, r=withoutboats
Stabilize `Option::filter`. Fixes #45860
This commit is contained in:
@@ -628,8 +628,6 @@ pub fn and_then<U, F: FnOnce(T) -> Option<U>>(self, f: F) -> Option<U> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// #![feature(option_filter)]
|
||||
///
|
||||
/// fn is_even(n: &i32) -> bool {
|
||||
/// n % 2 == 0
|
||||
/// }
|
||||
@@ -639,7 +637,7 @@ pub fn and_then<U, F: FnOnce(T) -> Option<U>>(self, f: F) -> Option<U> {
|
||||
/// assert_eq!(Some(4).filter(is_even), Some(4));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "option_filter", issue = "45860")]
|
||||
#[stable(feature = "option_filter", since = "1.27.0")]
|
||||
pub fn filter<P: FnOnce(&T) -> bool>(self, predicate: P) -> Self {
|
||||
if let Some(x) = self {
|
||||
if predicate(&x) {
|
||||
|
||||
@@ -76,7 +76,6 @@
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(from_ref)]
|
||||
#![feature(exhaustive_patterns)]
|
||||
#![feature(option_filter)]
|
||||
#![feature(quote)]
|
||||
#![feature(refcell_replace_swap)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
|
||||
Reference in New Issue
Block a user