+ /// Returns `true` if the result is [`Err`] wrapping a value matching the predicate.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// #![feature(is_some_with)]
+ /// use std::io::{Error, ErrorKind};
+ ///
+ /// let x: Result<u32, Error> = Err(Error::new(ErrorKind::NotFound, "!"));
+ /// assert_eq!(x.is_err_with(|x| x.kind() == ErrorKind::NotFound), true);
+ ///
+ /// let x: Result<u32, Error> = Err(Error::new(ErrorKind::PermissionDenied, "!"));
+ /// assert_eq!(x.is_err_with(|x| x.kind() == ErrorKind::NotFound), false);
+ ///
+ /// let x: Result<u32, Error> = Ok(123);
+ /// assert_eq!(x.is_err_with(|x| x.kind() == ErrorKind::NotFound), false);
+ /// ```
+ #[must_use]
+ #[inline]
+ #[unstable(feature = "is_some_with", issue = "93050")]
+ pub fn is_err_with(&self, f: impl FnOnce(&E) -> bool) -> bool {
+ matches!(self, Err(x) if f(x))
+ }
+