diff options
Diffstat (limited to 'src/librustc_error_codes/error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0638.md | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/librustc_error_codes/error_codes/E0638.md b/src/librustc_error_codes/error_codes/E0638.md index 29b7586b07b..14cd31502b6 100644 --- a/src/librustc_error_codes/error_codes/E0638.md +++ b/src/librustc_error_codes/error_codes/E0638.md @@ -10,23 +10,23 @@ For example, in the below example, since the enum is marked as on it. ```rust,ignore (pseudo-Rust) -use std::error::Error as StdError; - -#[non_exhaustive] pub enum Error { - Message(String), - Other, +#[non_exhaustive] +pub enum Error { + Message(String), + Other, } -impl StdError for Error { - fn description(&self) -> &str { +impl Display for Error { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { // This will not error, despite being marked as non_exhaustive, as this // enum is defined within the current crate, it can be matched // exhaustively. - match *self { - Message(ref s) => s, - Other => "other or unknown error", - } - } + let display = match self { + Message(s) => s, + Other => "other or unknown error", + }; + formatter.write_str(display) + } } ``` @@ -38,9 +38,9 @@ use mycrate::Error; // This will not error as the non_exhaustive Error enum has been matched with a // wildcard. match error { - Message(ref s) => ..., - Other => ..., - _ => ..., + Message(s) => ..., + Other => ..., + _ => ..., } ``` |
