Skip to content

Commit

Permalink
Auto merge of #91101 - birkenfeld:io_error_docs, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Nov 22, 2021
2 parents cd83a43 + 289eb78 commit 883a241
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions library/std/src/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
/// ```
Expand All @@ -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
Expand Down

0 comments on commit 883a241

Please sign in to comment.