@@ -542,26 +542,26 @@ impl<T, E> Result<T, E> {
542
542
matches ! ( * self , Ok ( _) )
543
543
}
544
544
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.
546
546
///
547
547
/// # Examples
548
548
///
549
549
/// ```
550
550
/// #![feature(is_some_with)]
551
551
///
552
552
/// 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);
554
554
///
555
555
/// 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);
557
557
///
558
558
/// 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);
560
560
/// ```
561
561
#[ must_use]
562
562
#[ inline]
563
563
#[ 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 {
565
565
matches ! ( self , Ok ( x) if f( x) )
566
566
}
567
567
@@ -586,7 +586,7 @@ impl<T, E> Result<T, E> {
586
586
!self . is_ok ( )
587
587
}
588
588
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.
590
590
///
591
591
/// # Examples
592
592
///
@@ -595,18 +595,18 @@ impl<T, E> Result<T, E> {
595
595
/// use std::io::{Error, ErrorKind};
596
596
///
597
597
/// 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);
599
599
///
600
600
/// 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);
602
602
///
603
603
/// 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);
605
605
/// ```
606
606
#[ must_use]
607
607
#[ inline]
608
608
#[ 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 {
610
610
matches ! ( self , Err ( x) if f( x) )
611
611
}
612
612
0 commit comments