diff --git a/src/version.rs b/src/version.rs index 2b903145..67626660 100644 --- a/src/version.rs +++ b/src/version.rs @@ -193,13 +193,7 @@ impl fmt::Display for SemVerError { } } -impl Error for SemVerError { - fn description(&self) -> &str { - match self { - &SemVerError::ParseError(ref m) => m, - } - } -} +impl Error for SemVerError {} /// A Result type for errors pub type Result = result::Result; diff --git a/src/version_req.rs b/src/version_req.rs index b4c67d58..be1cb7ee 100644 --- a/src/version_req.rs +++ b/src/version_req.rs @@ -167,13 +167,7 @@ pub enum ReqParseError { impl fmt::Display for ReqParseError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.description().fmt(f) - } -} - -impl Error for ReqParseError { - fn description(&self) -> &str { - match self { + let msg = match self { &InvalidVersionRequirement => "the given version requirement is invalid", &OpAlreadySet => { "you have already provided an operation, such as =, ~, or ^; only use one" @@ -186,10 +180,13 @@ impl Error for ReqParseError { "the given version requirement is not implemented, yet" } &DeprecatedVersionRequirement(_) => "This requirement is deprecated", - } + }; + msg.fmt(f) } } +impl Error for ReqParseError {} + impl From for ReqParseError { fn from(other: String) -> ReqParseError { match &*other {