diff --git a/crossbeam-channel/src/err.rs b/crossbeam-channel/src/err.rs index 468ce5cd8..4bf71440d 100644 --- a/crossbeam-channel/src/err.rs +++ b/crossbeam-channel/src/err.rs @@ -127,15 +127,7 @@ impl fmt::Display for SendError { } } -impl error::Error for SendError { - fn description(&self) -> &str { - "sending on a disconnected channel" - } - - fn cause(&self) -> Option<&dyn error::Error> { - None - } -} +impl error::Error for SendError {} impl SendError { /// Unwraps the message. @@ -175,18 +167,7 @@ impl fmt::Display for TrySendError { } } -impl error::Error for TrySendError { - fn description(&self) -> &str { - match *self { - TrySendError::Full(..) => "sending on a full channel", - TrySendError::Disconnected(..) => "sending on a disconnected channel", - } - } - - fn cause(&self) -> Option<&dyn error::Error> { - None - } -} +impl error::Error for TrySendError {} impl From> for TrySendError { fn from(err: SendError) -> TrySendError { @@ -249,15 +230,7 @@ impl fmt::Display for SendTimeoutError { } } -impl error::Error for SendTimeoutError { - fn description(&self) -> &str { - "sending on an empty and disconnected channel" - } - - fn cause(&self) -> Option<&dyn error::Error> { - None - } -} +impl error::Error for SendTimeoutError {} impl From> for SendTimeoutError { fn from(err: SendError) -> SendTimeoutError { @@ -312,15 +285,7 @@ impl fmt::Display for RecvError { } } -impl error::Error for RecvError { - fn description(&self) -> &str { - "receiving on an empty and disconnected channel" - } - - fn cause(&self) -> Option<&dyn error::Error> { - None - } -} +impl error::Error for RecvError {} impl fmt::Display for TryRecvError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -331,18 +296,7 @@ impl fmt::Display for TryRecvError { } } -impl error::Error for TryRecvError { - fn description(&self) -> &str { - match *self { - TryRecvError::Empty => "receiving on an empty channel", - TryRecvError::Disconnected => "receiving on an empty and disconnected channel", - } - } - - fn cause(&self) -> Option<&dyn error::Error> { - None - } -} +impl error::Error for TryRecvError {} impl From for TryRecvError { fn from(err: RecvError) -> TryRecvError { @@ -379,18 +333,7 @@ impl fmt::Display for RecvTimeoutError { } } -impl error::Error for RecvTimeoutError { - fn description(&self) -> &str { - match *self { - RecvTimeoutError::Timeout => "timed out waiting on receive operation", - RecvTimeoutError::Disconnected => "channel is empty and disconnected", - } - } - - fn cause(&self) -> Option<&dyn error::Error> { - None - } -} +impl error::Error for RecvTimeoutError {} impl From for RecvTimeoutError { fn from(err: RecvError) -> RecvTimeoutError { @@ -424,15 +367,7 @@ impl fmt::Display for TrySelectError { } } -impl error::Error for TrySelectError { - fn description(&self) -> &str { - "all operations in select would block" - } - - fn cause(&self) -> Option<&dyn error::Error> { - None - } -} +impl error::Error for TrySelectError {} impl fmt::Display for SelectTimeoutError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -440,12 +375,4 @@ impl fmt::Display for SelectTimeoutError { } } -impl error::Error for SelectTimeoutError { - fn description(&self) -> &str { - "timed out waiting on select" - } - - fn cause(&self) -> Option<&dyn error::Error> { - None - } -} +impl error::Error for SelectTimeoutError {} diff --git a/crossbeam-queue/src/err.rs b/crossbeam-queue/src/err.rs index 58ecee8b0..7b9757e8e 100644 --- a/crossbeam-queue/src/err.rs +++ b/crossbeam-queue/src/err.rs @@ -17,11 +17,7 @@ impl fmt::Display for PopError { } #[cfg(feature = "std")] -impl ::std::error::Error for PopError { - fn description(&self) -> &str { - "popping from an empty queue" - } -} +impl ::std::error::Error for PopError {} /// Error which occurs when pushing into a full queue. #[derive(Clone, Copy, Eq, PartialEq)] @@ -40,8 +36,4 @@ impl fmt::Display for PushError { } #[cfg(feature = "std")] -impl ::std::error::Error for PushError { - fn description(&self) -> &str { - "pushing into a full queue" - } -} +impl ::std::error::Error for PushError {}