Skip to content

Commit

Permalink
sync: add {TrySendError,SendTimeoutError}::into_inner (#6755)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmleinz authored Aug 7, 2024
1 parent 0ecf5f0 commit a491b16
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tokio/src/sync/mpsc/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ pub enum TrySendError<T> {
Closed(T),
}

impl<T> TrySendError<T> {
/// Consume the `TrySendError`, returning the unsent value.
pub fn into_inner(self) -> T {
match self {
TrySendError::Full(val) => val,
TrySendError::Closed(val) => val,
}
}
}

impl<T> fmt::Debug for TrySendError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Expand Down Expand Up @@ -123,6 +133,16 @@ cfg_time! {
Closed(T),
}

impl<T> SendTimeoutError<T> {
/// Consume the `SendTimeoutError`, returning the unsent value.
pub fn into_inner(self) -> T {
match self {
SendTimeoutError::Timeout(val) => val,
SendTimeoutError::Closed(val) => val,
}
}
}

impl<T> fmt::Debug for SendTimeoutError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Expand Down

0 comments on commit a491b16

Please sign in to comment.