Implement From<RecvError> for TryRecvError and RecvTimeoutError
This commit is contained in:
@@ -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")]
|
#[stable(feature = "mpsc_recv_timeout_error", since = "1.15.0")]
|
||||||
impl fmt::Display for RecvTimeoutError {
|
impl fmt::Display for RecvTimeoutError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
@@ -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")))]
|
#[cfg(all(test, not(target_os = "emscripten")))]
|
||||||
mod tests {
|
mod tests {
|
||||||
use env;
|
use env;
|
||||||
|
|||||||
Reference in New Issue
Block a user