sync: add {TrySendError,SendTimeoutError}::into_inner (#6755)

This commit is contained in:
Caleb Leinz (he/him)
2024-08-08 00:06:37 +02:00
committed by GitHub
parent 0ecf5f0f03
commit a491b16a89
+20
View File
@@ -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 {
@@ -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 {