Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: Add into_inner method on TrySendErrors #6755

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applies both places.

Suggested change
/// Consume the `TrySendError`, returning the unsent value
/// 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
Loading