We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0947857 + c301814 commit ebfe76cCopy full SHA for ebfe76c
exercises/error_handling/errorsn.rs
@@ -100,15 +100,12 @@ enum CreationError {
100
101
impl fmt::Display for CreationError {
102
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
103
- f.write_str((self as &dyn error::Error).description())
+ let description = match *self {
104
+ CreationError::Negative => "Number is negative",
105
+ CreationError::Zero => "Number is zero",
106
+ };
107
+ f.write_str(description)
108
}
109
110
-impl error::Error for CreationError {
- fn description(&self) -> &str {
- match *self {
- CreationError::Negative => "Negative",
111
- CreationError::Zero => "Zero",
112
- }
113
114
-}
+impl error::Error for CreationError {}
0 commit comments