Merge pull request #382 from bertonha/deprecated-description

This commit is contained in:
fmoko 2020-05-02 18:38:32 +02:00 committed by GitHub
commit ebfe76cdb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 9 deletions

View File

@ -100,15 +100,12 @@ enum CreationError {
impl fmt::Display for CreationError { impl fmt::Display for CreationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str((self as &dyn error::Error).description()) let description = match *self {
CreationError::Negative => "Number is negative",
CreationError::Zero => "Number is zero",
};
f.write_str(description)
} }
} }
impl error::Error for CreationError { impl error::Error for CreationError {}
fn description(&self) -> &str {
match *self {
CreationError::Negative => "Negative",
CreationError::Zero => "Zero",
}
}
}