提交 45dee47f 编写于 作者: M Mara Bos

Improve is_err_with example.

上级 148234ff
......@@ -589,14 +589,16 @@ pub const fn is_err(&self) -> bool {
/// # Examples
///
/// ```
/// let x: Result<u32, &str> = Err("abc");
/// assert_eq!(x.is_err_with(|x| x.len() > 1), true);
/// use std::io::{Error, ErrorKind};
///
/// let x: Result<u32, &str> = Err("");
/// assert_eq!(x.is_ok_with(|x| x.len() > 1), false);
/// 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, &str> = Ok(123);
/// assert_eq!(x.is_ok_with(|x| x.len() > 1), false);
/// let x: Result<u32, Error> = Err(Error::new(ErrorKind::PermissionDenied, "!"));
/// assert_eq!(x.is_ok_with(|x| x.kind() == ErrorKind::NotFound), false);
///
/// let x: Result<u32, Error> = Ok(123);
/// assert_eq!(x.is_ok_with(|x| x.kind() == ErrorKind::NotFound), false);
/// ```
#[must_use]
#[inline]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册