From ae64da2d2d00cc188f4fe6be9e8dc4ce59dc4ba2 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 8 Nov 2021 18:01:52 +0000 Subject: [PATCH] io::ErrorKind: Discuss matching Closes #89175 Signed-off-by: Ian Jackson --- library/std/src/io/error.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 3da28695b34bd..0198b2fd3274b 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -88,6 +88,15 @@ 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, you may need to cut-and-paste the current list of +/// errors from here into your test code. This seems counterintuitive, but is correct, +/// as set out in [this blog post](https://diziet.dreamwidth.org/9894.html#diziet-what-to-do). #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated)]