diff options
| author | bors <bors@rust-lang.org> | 2021-11-22 13:56:51 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-11-22 13:56:51 +0000 |
| commit | 883a241c081ccd0518a6851a975afb63ed2f568c (patch) | |
| tree | ecd81dcb2fb2546643bf17be552bf01599aeb1ea | |
| parent | cd83a437cc2b9c453f39996f664d2cc10611375b (diff) | |
| parent | 289eb786d4fa6316fc99c537bb19de86621ede16 (diff) | |
| download | rust-883a241c081ccd0518a6851a975afb63ed2f568c.tar.gz rust-883a241c081ccd0518a6851a975afb63ed2f568c.zip | |
Auto merge of #91101 - birkenfeld:io_error_docs, r=Mark-Simulacrum
Mention std::io::Error::from(ErrorKind) in Error::new() docs This conversion is not very discoverable for the cases where an error is required without extra payload.
| -rw-r--r-- | library/std/src/io/error.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 3da28695b34..d93c6172cfc 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -392,6 +392,9 @@ impl Error { /// originate from the OS itself. The `error` argument is an arbitrary /// payload which will be contained in this [`Error`]. /// + /// If no extra payload is required, use the `From` conversion from + /// `ErrorKind`. + /// /// # Examples /// /// ``` @@ -402,6 +405,9 @@ impl Error { /// /// // errors can also be created from other errors /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// + /// // creating an error without payload + /// let eof_error = Error::from(ErrorKind::UnexpectedEof); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn new<E>(kind: ErrorKind, error: E) -> Error |
