Skip to content

Commit ebfe76c

Browse files
author
fmoko
authored
Merge pull request #382 from bertonha/deprecated-description
2 parents 0947857 + c301814 commit ebfe76c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

exercises/error_handling/errorsn.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,12 @@ enum CreationError {
100100

101101
impl fmt::Display for CreationError {
102102
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
103-
f.write_str((self as &dyn error::Error).description())
103+
let description = match *self {
104+
CreationError::Negative => "Number is negative",
105+
CreationError::Zero => "Number is zero",
106+
};
107+
f.write_str(description)
104108
}
105109
}
106110

107-
impl error::Error for CreationError {
108-
fn description(&self) -> &str {
109-
match *self {
110-
CreationError::Negative => "Negative",
111-
CreationError::Zero => "Zero",
112-
}
113-
}
114-
}
111+
impl error::Error for CreationError {}

0 commit comments

Comments
 (0)