diff --git a/tokio/src/sync/mpsc/error.rs b/tokio/src/sync/mpsc/error.rs index 2fc24b38d83..9fef7fd9c03 100644 --- a/tokio/src/sync/mpsc/error.rs +++ b/tokio/src/sync/mpsc/error.rs @@ -36,6 +36,16 @@ pub enum TrySendError { Closed(T), } +impl TrySendError { + /// Consume the `TrySendError`, returning the unsent value. + pub fn into_inner(self) -> T { + match self { + TrySendError::Full(val) => val, + TrySendError::Closed(val) => val, + } + } +} + impl fmt::Debug for TrySendError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { @@ -123,6 +133,16 @@ cfg_time! { Closed(T), } + impl SendTimeoutError { + /// Consume the `SendTimeoutError`, returning the unsent value. + pub fn into_inner(self) -> T { + match self { + SendTimeoutError::Timeout(val) => val, + SendTimeoutError::Closed(val) => val, + } + } + } + impl fmt::Debug for SendTimeoutError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self {