From 3f0f40904c18bce9915b5fe2a1d017f3906c0d26 Mon Sep 17 00:00:00 2001 From: Erik Hofmayer Date: Sun, 20 Sep 2020 15:50:44 +0200 Subject: [PATCH 1/2] Documented From impls in std/sync/mpsc/mod.rs --- library/std/src/sync/mpsc/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/std/src/sync/mpsc/mod.rs b/library/std/src/sync/mpsc/mod.rs index 073f969bbe25b..d23a8161a229c 100644 --- a/library/std/src/sync/mpsc/mod.rs +++ b/library/std/src/sync/mpsc/mod.rs @@ -1531,6 +1531,9 @@ impl error::Error for TrySendError { #[stable(feature = "mpsc_error_conversions", since = "1.24.0")] impl From> for TrySendError { + /// Converts a `SendError` into a `TrySendError`. + /// This conversion always returns a `TrySendError::Disconnected` containing the data in the `SendError`. + /// No data is allocated on the heap. fn from(err: SendError) -> TrySendError { 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 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 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, From 16eee2a04a4c3a93d398728d7a0c05a8afb6ca94 Mon Sep 17 00:00:00 2001 From: Erik Hofmayer Date: Mon, 21 Sep 2020 21:31:01 +0200 Subject: [PATCH 2/2] Applied review comments --- library/std/src/sync/mpsc/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/std/src/sync/mpsc/mod.rs b/library/std/src/sync/mpsc/mod.rs index d23a8161a229c..dc13c9433f121 100644 --- a/library/std/src/sync/mpsc/mod.rs +++ b/library/std/src/sync/mpsc/mod.rs @@ -1532,7 +1532,9 @@ impl error::Error for TrySendError { #[stable(feature = "mpsc_error_conversions", since = "1.24.0")] impl From> for TrySendError { /// Converts a `SendError` into a `TrySendError`. + /// /// This conversion always returns a `TrySendError::Disconnected` containing the data in the `SendError`. + /// /// No data is allocated on the heap. fn from(err: SendError) -> TrySendError { match err { @@ -1580,7 +1582,9 @@ impl error::Error for TryRecvError { #[stable(feature = "mpsc_error_conversions", since = "1.24.0")] impl From 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 { @@ -1613,7 +1617,9 @@ impl error::Error for RecvTimeoutError { #[stable(feature = "mpsc_error_conversions", since = "1.24.0")] impl From 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 {