Skip to content

Commit

Permalink
Rollup merge of #94273 - Dylan-DPC:doc/errorkind, r=joshtriplett
Browse files Browse the repository at this point in the history
add matching doc to errorkind

Rework of #90706
  • Loading branch information
matthiaskrgr authored Feb 24, 2022
2 parents 3cd1dc1 + 3f4b039 commit aa0b7ac
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions library/std/src/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,19 @@ struct Custom {
/// It is used with the [`io::Error`] type.
///
/// [`io::Error`]: Error
///
/// # Handling errors and matching on `ErrorKind`
///
/// In application code, use `match` for the `ErrorKind` values you are
/// expecting; use `_` to match "all other errors".
///
/// In comprehensive and thorough tests that want to verify that a test doesn't
/// return any known incorrect error kind, you may want to cut-and-paste the
/// current full list of errors from here into your test code, and then match
/// `_` as the correct case. This seems counterintuitive, but it will make your
/// tests more robust. In particular, if you want to verify that your code does
/// produce an unrecognized error kind, the robust solution is to check for all
/// the recognized error kinds and fail in those cases.
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
Expand Down

0 comments on commit aa0b7ac

Please sign in to comment.