Skip to content

Commit 73ed6cf

Browse files
committed
Implement From<RecvError> for TryRecvError and RecvTimeoutError
1 parent 61af754 commit 73ed6cf

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/libstd/sync/mpsc/mod.rs

+18
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,15 @@ impl error::Error for TryRecvError {
16771677
}
16781678
}
16791679

1680+
#[stable(feature = "mpsc_recv_error_from", since = "1.23.0")]
1681+
impl From<RecvError> for TryRecvError {
1682+
fn from(err: RecvError) -> TryRecvError {
1683+
match err {
1684+
RecvError => TryRecvError::Disconnected,
1685+
}
1686+
}
1687+
}
1688+
16801689
#[stable(feature = "mpsc_recv_timeout_error", since = "1.15.0")]
16811690
impl fmt::Display for RecvTimeoutError {
16821691
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -1709,6 +1718,15 @@ impl error::Error for RecvTimeoutError {
17091718
}
17101719
}
17111720

1721+
#[stable(feature = "mpsc_recv_error_from", since = "1.23.0")]
1722+
impl From<RecvError> for RecvTimeoutError {
1723+
fn from(err: RecvError) -> RecvTimeoutError {
1724+
match err {
1725+
RecvError => RecvTimeoutError::Disconnected,
1726+
}
1727+
}
1728+
}
1729+
17121730
#[cfg(all(test, not(target_os = "emscripten")))]
17131731
mod tests {
17141732
use env;

0 commit comments

Comments
 (0)