Skip to content

Commit

Permalink
Auto merge of #110019 - jplatte:jplatte/stabilize-is-some-and, r=Amanieu
Browse files Browse the repository at this point in the history
Stabilize is_some_and

This stabilizes the following public API:

```rust
impl<T> Option<T> {
    pub fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool;
}

impl<T, E> Result<T, E> {
    pub fn is_ok_and(self, f: impl FnOnce(T) -> bool) -> bool;
    pub fn is_err_and(self, f: impl FnOnce(E) -> bool) -> bool;
}
```

Closes #93050 (tracking issue).

`@rustbot` label +T-libs-api -T-libs
  • Loading branch information
bors committed Apr 7, 2023
2 parents 97879ce + 443928f commit b6f6104
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 13 deletions.
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#![feature(box_patterns)]
#![feature(decl_macro)]
#![feature(if_let_guard)]
#![feature(is_some_and)]
#![feature(is_sorted)]
#![feature(let_chains)]
#![feature(proc_macro_internals)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_const_eval/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Rust MIR: a lowered representation of Rust.
#![feature(try_blocks)]
#![feature(yeet_expr)]
#![feature(if_let_guard)]
#![feature(is_some_and)]
#![recursion_limit = "256"]

#[macro_use]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ This API is completely unstable and subject to change.
#![feature(lazy_cell)]
#![feature(slice_partition_dedup)]
#![feature(try_blocks)]
#![feature(is_some_and)]
#![feature(type_alias_impl_trait)]
#![recursion_limit = "256"]

Expand Down
4 changes: 1 addition & 3 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,6 @@ impl<T> Option<T> {
/// # Examples
///
/// ```
/// #![feature(is_some_and)]
///
/// let x: Option<u32> = Some(2);
/// assert_eq!(x.is_some_and(|x| x > 1), true);
///
Expand All @@ -618,7 +616,7 @@ impl<T> Option<T> {
/// ```
#[must_use]
#[inline]
#[unstable(feature = "is_some_and", issue = "93050")]
#[stable(feature = "is_some_and", since = "CURRENT_RUSTC_VERSION")]
pub fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool {
match self {
None => false,
Expand Down
7 changes: 2 additions & 5 deletions library/core/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,6 @@ impl<T, E> Result<T, E> {
/// # Examples
///
/// ```
/// #![feature(is_some_and)]
///
/// let x: Result<u32, &str> = Ok(2);
/// assert_eq!(x.is_ok_and(|x| x > 1), true);
///
Expand All @@ -558,7 +556,7 @@ impl<T, E> Result<T, E> {
/// ```
#[must_use]
#[inline]
#[unstable(feature = "is_some_and", issue = "93050")]
#[stable(feature = "is_some_and", since = "CURRENT_RUSTC_VERSION")]
pub fn is_ok_and(self, f: impl FnOnce(T) -> bool) -> bool {
match self {
Err(_) => false,
Expand Down Expand Up @@ -590,7 +588,6 @@ impl<T, E> Result<T, E> {
/// # Examples
///
/// ```
/// #![feature(is_some_and)]
/// use std::io::{Error, ErrorKind};
///
/// let x: Result<u32, Error> = Err(Error::new(ErrorKind::NotFound, "!"));
Expand All @@ -604,7 +601,7 @@ impl<T, E> Result<T, E> {
/// ```
#[must_use]
#[inline]
#[unstable(feature = "is_some_and", issue = "93050")]
#[stable(feature = "is_some_and", since = "CURRENT_RUSTC_VERSION")]
pub fn is_err_and(self, f: impl FnOnce(E) -> bool) -> bool {
match self {
Ok(_) => false,
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@
#![feature(hashmap_internals)]
#![feature(ip)]
#![feature(ip_in_core)]
#![feature(is_some_and)]
#![feature(maybe_uninit_slice)]
#![feature(maybe_uninit_write_slice)]
#![feature(panic_can_unwind)]
Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#![feature(io_error_more)]
#![feature(variant_count)]
#![feature(yeet_expr)]
#![feature(is_some_and)]
#![feature(nonzero_ops)]
#![feature(local_key_cell_methods)]
#![feature(is_terminal)]
Expand Down

0 comments on commit b6f6104

Please sign in to comment.