Rollup merge of #94765 - m-ou-se:is-some-and, r=Dylan-DPC
Rename is_{some,ok,err}_with to is_{some,ok,err}_and. This renames `is_{some,ok,err}_with` to `is_{some,ok,err}_and`. This was discussed on the [tracking issue](https://github.com/rust-lang/rust/issues/93050).
This commit is contained in:
commit
6d66020594
2 changed files with 15 additions and 15 deletions
|
@ -551,7 +551,7 @@ impl<T> Option<T> {
|
|||
matches!(*self, Some(_))
|
||||
}
|
||||
|
||||
/// Returns `true` if the option is a [`Some`] wrapping a value matching the predicate.
|
||||
/// Returns `true` if the option is a [`Some`] and the value inside of it matches a predicate.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -559,18 +559,18 @@ impl<T> Option<T> {
|
|||
/// #![feature(is_some_with)]
|
||||
///
|
||||
/// let x: Option<u32> = Some(2);
|
||||
/// assert_eq!(x.is_some_with(|&x| x > 1), true);
|
||||
/// assert_eq!(x.is_some_and(|&x| x > 1), true);
|
||||
///
|
||||
/// let x: Option<u32> = Some(0);
|
||||
/// assert_eq!(x.is_some_with(|&x| x > 1), false);
|
||||
/// assert_eq!(x.is_some_and(|&x| x > 1), false);
|
||||
///
|
||||
/// let x: Option<u32> = None;
|
||||
/// assert_eq!(x.is_some_with(|&x| x > 1), false);
|
||||
/// assert_eq!(x.is_some_and(|&x| x > 1), false);
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[unstable(feature = "is_some_with", issue = "93050")]
|
||||
pub fn is_some_with(&self, f: impl FnOnce(&T) -> bool) -> bool {
|
||||
pub fn is_some_and(&self, f: impl FnOnce(&T) -> bool) -> bool {
|
||||
matches!(self, Some(x) if f(x))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue