Skip to content

Commit

Permalink
Implement Debug for async futures/streams
Browse files Browse the repository at this point in the history
  • Loading branch information
jf2048 committed Oct 23, 2022
1 parent 8bb9ce0 commit 35fa508
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ impl<'a, T> SendFut<'a, T> {
}
}

impl<'a, T> std::fmt::Debug for SendFut<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SendFut").finish()
}
}

#[allow(clippy::needless_lifetimes)] // False positive, see https://github.com/rust-lang/rust-clippy/issues/5787
#[pinned_drop]
impl<'a, T> PinnedDrop for SendFut<'a, T> {
Expand Down Expand Up @@ -253,6 +259,7 @@ impl<'a, T> FusedFuture for SendFut<'a, T> {
/// A sink that allows sending values into a channel.
///
/// Can be created via [`Sender::sink`] or [`Sender::into_sink`].
#[derive(Debug)]
pub struct SendSink<'a, T>(SendFut<'a, T>);

impl<'a, T> SendSink<'a, T> {
Expand Down Expand Up @@ -457,6 +464,12 @@ impl<'a, T> RecvFut<'a, T> {
}
}

impl<'a, T> std::fmt::Debug for RecvFut<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RecvFut").finish()
}
}

impl<'a, T> Drop for RecvFut<'a, T> {
fn drop(&mut self) {
self.reset_hook();
Expand All @@ -480,6 +493,7 @@ impl<'a, T> FusedFuture for RecvFut<'a, T> {
/// A stream which allows asynchronously receiving messages.
///
/// Can be created via [`Receiver::stream`] or [`Receiver::into_stream`].
#[derive(Debug)]
pub struct RecvStream<'a, T>(RecvFut<'a, T>);

impl<'a, T> RecvStream<'a, T> {
Expand Down

0 comments on commit 35fa508

Please # to comment.