Rollup merge of #49575 - tmccombs:option-filter-stabilize, r=withoutboats
Stabilize `Option::filter`. Fixes #45860
This commit is contained in:
commit
5ee5de10d2
2 changed files with 1 additions and 4 deletions
|
@ -628,8 +628,6 @@ impl<T> Option<T> {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![feature(option_filter)]
|
|
||||||
///
|
|
||||||
/// fn is_even(n: &i32) -> bool {
|
/// fn is_even(n: &i32) -> bool {
|
||||||
/// n % 2 == 0
|
/// n % 2 == 0
|
||||||
/// }
|
/// }
|
||||||
|
@ -639,7 +637,7 @@ impl<T> Option<T> {
|
||||||
/// assert_eq!(Some(4).filter(is_even), Some(4));
|
/// assert_eq!(Some(4).filter(is_even), Some(4));
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[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 {
|
pub fn filter<P: FnOnce(&T) -> bool>(self, predicate: P) -> Self {
|
||||||
if let Some(x) = self {
|
if let Some(x) = self {
|
||||||
if predicate(&x) {
|
if predicate(&x) {
|
||||||
|
|
|
@ -76,7 +76,6 @@ This API is completely unstable and subject to change.
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(from_ref)]
|
#![feature(from_ref)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
#![feature(option_filter)]
|
|
||||||
#![feature(quote)]
|
#![feature(quote)]
|
||||||
#![feature(refcell_replace_swap)]
|
#![feature(refcell_replace_swap)]
|
||||||
#![feature(rustc_diagnostic_macros)]
|
#![feature(rustc_diagnostic_macros)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue