Documented From impls in std/sync/mpsc/mod.rs

This commit is contained in:
Erik Hofmayer 2020-09-20 15:50:44 +02:00
parent 5e449b9adf
commit 3f0f40904c
1 changed files with 9 additions and 0 deletions

View File

@ -1531,6 +1531,9 @@ impl<T: Send> error::Error for TrySendError<T> {
#[stable(feature = "mpsc_error_conversions", since = "1.24.0")]
impl<T> From<SendError<T>> for TrySendError<T> {
/// Converts a `SendError<T>` into a `TrySendError<T>`.
/// This conversion always returns a `TrySendError::Disconnected` containing the data in the `SendError<T>`.
/// No data is allocated on the heap.
fn from(err: SendError<T>) -> TrySendError<T> {
match err {
SendError(t) => TrySendError::Disconnected(t),
@ -1576,6 +1579,9 @@ impl error::Error for TryRecvError {
#[stable(feature = "mpsc_error_conversions", since = "1.24.0")]
impl From<RecvError> for TryRecvError {
/// Converts a `RecvError` into a `TryRecvError`.
/// This conversion always returns `TryRecvError::Disconnected`.
/// No data is allocated on the heap.
fn from(err: RecvError) -> TryRecvError {
match err {
RecvError => TryRecvError::Disconnected,
@ -1606,6 +1612,9 @@ impl error::Error for RecvTimeoutError {
#[stable(feature = "mpsc_error_conversions", since = "1.24.0")]
impl From<RecvError> for RecvTimeoutError {
/// Converts a `RecvError` into a `RecvTimeoutError`.
/// This conversion always returns `RecvTimeoutError::Disconnected`.
/// No data is allocated on the heap.
fn from(err: RecvError) -> RecvTimeoutError {
match err {
RecvError => RecvTimeoutError::Disconnected,