Skip to content

Commit a491b16

Browse files
authored
sync: add {TrySendError,SendTimeoutError}::into_inner (#6755)
1 parent 0ecf5f0 commit a491b16

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tokio/src/sync/mpsc/error.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ pub enum TrySendError<T> {
3636
Closed(T),
3737
}
3838

39+
impl<T> TrySendError<T> {
40+
/// Consume the `TrySendError`, returning the unsent value.
41+
pub fn into_inner(self) -> T {
42+
match self {
43+
TrySendError::Full(val) => val,
44+
TrySendError::Closed(val) => val,
45+
}
46+
}
47+
}
48+
3949
impl<T> fmt::Debug for TrySendError<T> {
4050
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4151
match *self {
@@ -123,6 +133,16 @@ cfg_time! {
123133
Closed(T),
124134
}
125135

136+
impl<T> SendTimeoutError<T> {
137+
/// Consume the `SendTimeoutError`, returning the unsent value.
138+
pub fn into_inner(self) -> T {
139+
match self {
140+
SendTimeoutError::Timeout(val) => val,
141+
SendTimeoutError::Closed(val) => val,
142+
}
143+
}
144+
}
145+
126146
impl<T> fmt::Debug for SendTimeoutError<T> {
127147
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
128148
match *self {

0 commit comments

Comments
 (0)