mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-26 00:00:16 +02:00
sync: impl Error for mpsc error types (#937)
This commit is contained in:
@@ -284,3 +284,18 @@ impl<T> From<(T, chan::TrySendError)> for TrySendError<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===== impl RecvError =====
|
||||
|
||||
impl fmt::Display for RecvError {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
use std::error::Error;
|
||||
write!(fmt, "{}", self.description())
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::error::Error for RecvError {
|
||||
fn description(&self) -> &str {
|
||||
"channel closed"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,3 +180,18 @@ impl<T> From<(T, chan::TrySendError)> for UnboundedTrySendError<T> {
|
||||
UnboundedTrySendError(value)
|
||||
}
|
||||
}
|
||||
|
||||
// ===== impl UnboundedRecvError =====
|
||||
|
||||
impl fmt::Display for UnboundedRecvError {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
use std::error::Error;
|
||||
write!(fmt, "{}", self.description())
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::error::Error for UnboundedRecvError {
|
||||
fn description(&self) -> &str {
|
||||
"channel closed"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#![deny(warnings)]
|
||||
|
||||
extern crate tokio_sync;
|
||||
|
||||
use tokio_sync::mpsc::error;
|
||||
|
||||
fn is_error<T: ::std::error::Error + Send + Sync>() {}
|
||||
|
||||
#[test]
|
||||
fn error_bound() {
|
||||
is_error::<error::RecvError>();
|
||||
is_error::<error::SendError>();
|
||||
is_error::<error::TrySendError<()>>();
|
||||
is_error::<error::UnboundedRecvError>();
|
||||
is_error::<error::UnboundedSendError>();
|
||||
is_error::<error::UnboundedTrySendError<()>>();
|
||||
}
|
||||
Reference in New Issue
Block a user