Skip to content

Commit

Permalink
Implement From<SendError<T>> for TrySendError<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
ia0 committed Oct 30, 2017
1 parent 73ed6cf commit 448215d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/libstd/sync/mpsc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,15 @@ impl<T: Send> error::Error for TrySendError<T> {
}
}

#[stable(feature = "mpsc_error_conversions", since = "1.23.0")]
impl<T> From<SendError<T>> for TrySendError<T> {
fn from(err: SendError<T>) -> TrySendError<T> {
match err {
SendError(t) => TrySendError::Disconnected(t),
}
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Display for RecvError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down Expand Up @@ -1677,7 +1686,7 @@ impl error::Error for TryRecvError {
}
}

#[stable(feature = "mpsc_recv_error_from", since = "1.23.0")]
#[stable(feature = "mpsc_error_conversions", since = "1.23.0")]
impl From<RecvError> for TryRecvError {
fn from(err: RecvError) -> TryRecvError {
match err {
Expand Down Expand Up @@ -1718,7 +1727,7 @@ impl error::Error for RecvTimeoutError {
}
}

#[stable(feature = "mpsc_recv_error_from", since = "1.23.0")]
#[stable(feature = "mpsc_error_conversions", since = "1.23.0")]
impl From<RecvError> for RecvTimeoutError {
fn from(err: RecvError) -> RecvTimeoutError {
match err {
Expand Down

0 comments on commit 448215d

Please sign in to comment.