@@ -551,19 +551,22 @@ impl<T, E> Result<T, E> {
551
551
/// #![feature(is_some_with)]
552
552
///
553
553
/// let x: Result<u32, &str> = Ok(2);
554
- /// assert_eq!(x.is_ok_and(|& x| x > 1), true);
554
+ /// assert_eq!(x.is_ok_and(|x| x > 1), true);
555
555
///
556
556
/// let x: Result<u32, &str> = Ok(0);
557
- /// assert_eq!(x.is_ok_and(|& x| x > 1), false);
557
+ /// assert_eq!(x.is_ok_and(|x| x > 1), false);
558
558
///
559
559
/// let x: Result<u32, &str> = Err("hey");
560
- /// assert_eq!(x.is_ok_and(|& x| x > 1), false);
560
+ /// assert_eq!(x.is_ok_and(|x| x > 1), false);
561
561
/// ```
562
562
#[ must_use]
563
563
#[ inline]
564
564
#[ unstable( feature = "is_some_with" , issue = "93050" ) ]
565
- pub fn is_ok_and ( & self , f : impl FnOnce ( & T ) -> bool ) -> bool {
566
- matches ! ( self , Ok ( x) if f( x) )
565
+ pub fn is_ok_and ( self , f : impl FnOnce ( T ) -> bool ) -> bool {
566
+ match self {
567
+ Err ( _) => false ,
568
+ Ok ( x) => f ( x) ,
569
+ }
567
570
}
568
571
569
572
/// Returns `true` if the result is [`Err`].
@@ -607,8 +610,11 @@ impl<T, E> Result<T, E> {
607
610
#[ must_use]
608
611
#[ inline]
609
612
#[ unstable( feature = "is_some_with" , issue = "93050" ) ]
610
- pub fn is_err_and ( & self , f : impl FnOnce ( & E ) -> bool ) -> bool {
611
- matches ! ( self , Err ( x) if f( x) )
613
+ pub fn is_err_and ( self , f : impl FnOnce ( E ) -> bool ) -> bool {
614
+ match self {
615
+ Ok ( _) => false ,
616
+ Err ( e) => f ( e) ,
617
+ }
612
618
}
613
619
614
620
/////////////////////////////////////////////////////////////////////////
0 commit comments