Skip to content

Commit

Permalink
Implement From<RecvError> for TryRecvError and RecvTimeoutError
Browse files Browse the repository at this point in the history
  • Loading branch information
ia0 committed Oct 24, 2017
1 parent 61af754 commit 73ed6cf
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/libstd/sync/mpsc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,15 @@ impl error::Error for TryRecvError {
}
}

#[stable(feature = "mpsc_recv_error_from", since = "1.23.0")]
impl From<RecvError> for TryRecvError {
fn from(err: RecvError) -> TryRecvError {
match err {
RecvError => TryRecvError::Disconnected,
}
}
}

#[stable(feature = "mpsc_recv_timeout_error", since = "1.15.0")]
impl fmt::Display for RecvTimeoutError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down Expand Up @@ -1709,6 +1718,15 @@ impl error::Error for RecvTimeoutError {
}
}

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

#[cfg(all(test, not(target_os = "emscripten")))]
mod tests {
use env;
Expand Down

0 comments on commit 73ed6cf

Please sign in to comment.