Skip to content

Commit 6d66020

Browse files
authored
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](#93050).
2 parents ab85165 + 7c7411f commit 6d66020

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

Diff for: library/core/src/option.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -551,26 +551,26 @@ impl<T> Option<T> {
551551
matches!(*self, Some(_))
552552
}
553553

554-
/// Returns `true` if the option is a [`Some`] wrapping a value matching the predicate.
554+
/// Returns `true` if the option is a [`Some`] and the value inside of it matches a predicate.
555555
///
556556
/// # Examples
557557
///
558558
/// ```
559559
/// #![feature(is_some_with)]
560560
///
561561
/// let x: Option<u32> = Some(2);
562-
/// assert_eq!(x.is_some_with(|&x| x > 1), true);
562+
/// assert_eq!(x.is_some_and(|&x| x > 1), true);
563563
///
564564
/// let x: Option<u32> = Some(0);
565-
/// assert_eq!(x.is_some_with(|&x| x > 1), false);
565+
/// assert_eq!(x.is_some_and(|&x| x > 1), false);
566566
///
567567
/// let x: Option<u32> = None;
568-
/// assert_eq!(x.is_some_with(|&x| x > 1), false);
568+
/// assert_eq!(x.is_some_and(|&x| x > 1), false);
569569
/// ```
570570
#[must_use]
571571
#[inline]
572572
#[unstable(feature = "is_some_with", issue = "93050")]
573-
pub fn is_some_with(&self, f: impl FnOnce(&T) -> bool) -> bool {
573+
pub fn is_some_and(&self, f: impl FnOnce(&T) -> bool) -> bool {
574574
matches!(self, Some(x) if f(x))
575575
}
576576

Diff for: library/core/src/result.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -542,26 +542,26 @@ impl<T, E> Result<T, E> {
542542
matches!(*self, Ok(_))
543543
}
544544

545-
/// Returns `true` if the result is [`Ok`] wrapping a value matching the predicate.
545+
/// Returns `true` if the result is [`Ok`] and the value inside of it matches a predicate.
546546
///
547547
/// # Examples
548548
///
549549
/// ```
550550
/// #![feature(is_some_with)]
551551
///
552552
/// let x: Result<u32, &str> = Ok(2);
553-
/// assert_eq!(x.is_ok_with(|&x| x > 1), true);
553+
/// assert_eq!(x.is_ok_and(|&x| x > 1), true);
554554
///
555555
/// let x: Result<u32, &str> = Ok(0);
556-
/// assert_eq!(x.is_ok_with(|&x| x > 1), false);
556+
/// assert_eq!(x.is_ok_and(|&x| x > 1), false);
557557
///
558558
/// let x: Result<u32, &str> = Err("hey");
559-
/// assert_eq!(x.is_ok_with(|&x| x > 1), false);
559+
/// assert_eq!(x.is_ok_and(|&x| x > 1), false);
560560
/// ```
561561
#[must_use]
562562
#[inline]
563563
#[unstable(feature = "is_some_with", issue = "93050")]
564-
pub fn is_ok_with(&self, f: impl FnOnce(&T) -> bool) -> bool {
564+
pub fn is_ok_and(&self, f: impl FnOnce(&T) -> bool) -> bool {
565565
matches!(self, Ok(x) if f(x))
566566
}
567567

@@ -586,7 +586,7 @@ impl<T, E> Result<T, E> {
586586
!self.is_ok()
587587
}
588588

589-
/// Returns `true` if the result is [`Err`] wrapping a value matching the predicate.
589+
/// Returns `true` if the result is [`Err`] and the value inside of it matches a predicate.
590590
///
591591
/// # Examples
592592
///
@@ -595,18 +595,18 @@ impl<T, E> Result<T, E> {
595595
/// use std::io::{Error, ErrorKind};
596596
///
597597
/// let x: Result<u32, Error> = Err(Error::new(ErrorKind::NotFound, "!"));
598-
/// assert_eq!(x.is_err_with(|x| x.kind() == ErrorKind::NotFound), true);
598+
/// assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), true);
599599
///
600600
/// let x: Result<u32, Error> = Err(Error::new(ErrorKind::PermissionDenied, "!"));
601-
/// assert_eq!(x.is_err_with(|x| x.kind() == ErrorKind::NotFound), false);
601+
/// assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false);
602602
///
603603
/// let x: Result<u32, Error> = Ok(123);
604-
/// assert_eq!(x.is_err_with(|x| x.kind() == ErrorKind::NotFound), false);
604+
/// assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false);
605605
/// ```
606606
#[must_use]
607607
#[inline]
608608
#[unstable(feature = "is_some_with", issue = "93050")]
609-
pub fn is_err_with(&self, f: impl FnOnce(&E) -> bool) -> bool {
609+
pub fn is_err_and(&self, f: impl FnOnce(&E) -> bool) -> bool {
610610
matches!(self, Err(x) if f(x))
611611
}
612612

0 commit comments

Comments
 (0)