Remove usage of deprecated std::error::Error methods (#1206) (#1245)

This commit is contained in:
Steffen Butzer
2019-07-03 23:06:03 -07:00
committed by Carl Lerche
parent 516251052d
commit 0651f09427
17 changed files with 70 additions and 186 deletions
+1 -11
View File
@@ -147,17 +147,7 @@ impl<T> DeadlineError<T> {
}
}
impl<T: error::Error> error::Error for DeadlineError<T> {
fn description(&self) -> &str {
use self::Kind::*;
match self.0 {
Inner(ref e) => e.description(),
Elapsed => "deadline has elapsed",
Timer(ref e) => e.description(),
}
}
}
impl<T: error::Error> error::Error for DeadlineError<T> {}
impl<T: fmt::Display> fmt::Display for DeadlineError<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
+7 -12
View File
@@ -58,20 +58,15 @@ impl Error {
}
}
impl error::Error for Error {
fn description(&self) -> &str {
use self::Kind::*;
match self.0 {
Shutdown => "timer is shutdown",
AtCapacity => "timer is at capacity and cannot create a new entry",
}
}
}
impl error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
use std::error::Error;
self.description().fmt(fmt)
use self::Kind::*;
let descr = match self.0 {
Shutdown => "timer is shutdown",
AtCapacity => "timer is at capacity and cannot create a new entry",
};
write!(fmt, "{}", descr)
}
}