about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2022-01-18 22:53:43 +0100
committerMara Bos <m-ou.se@m-ou.se>2022-01-18 22:53:43 +0100
commit45dee47fec4b04fc642361cbf1f2f9fc0e0ad53d (patch)
tree7d02a2afb4d5866bebd77f85664655619ff3e720
parent148234ff73aa649178f92f529b9f5b0fc5adf3ed (diff)
downloadrust-45dee47fec4b04fc642361cbf1f2f9fc0e0ad53d.tar.gz
rust-45dee47fec4b04fc642361cbf1f2f9fc0e0ad53d.zip
Improve is_err_with example.
-rw-r--r--library/core/src/result.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/library/core/src/result.rs b/library/core/src/result.rs
index 82d99cef458..9991112e7f5 100644
--- a/library/core/src/result.rs
+++ b/library/core/src/result.rs
@@ -589,14 +589,16 @@ impl<T, E> Result<T, E> {
     /// # 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]