Skip to content

Commit 97603c0

Browse files
committed
feat: implement Debug trait for more types
1 parent 3c47bcc commit 97603c0

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

src/async.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::{
77
any::Any,
88
ops::Deref,
99
};
10+
use std::fmt::{Debug, Formatter};
1011
use crate::*;
1112
use futures_core::{stream::{Stream, FusedStream}, future::FusedFuture};
1213
use futures_sink::Sink;
@@ -141,6 +142,12 @@ pub struct SendFut<'a, T> {
141142
hook: Option<SendState<T>>,
142143
}
143144

145+
impl<'a, T> Debug for SendFut<'a, T> {
146+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
147+
f.debug_struct("SendFut").finish()
148+
}
149+
}
150+
144151
impl<T> std::marker::Unpin for SendFut<'_, T> {}
145152

146153
impl<'a, T> SendFut<'a, T> {
@@ -282,6 +289,12 @@ impl<'a, T> SendSink<'a, T> {
282289
}
283290
}
284291

292+
impl<'a, T> Debug for SendSink<'a, T> {
293+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
294+
f.debug_struct("SendSink").finish()
295+
}
296+
}
297+
285298
impl<'a, T> Sink<T> for SendSink<'a, T> {
286299
type Error = SendError<T>;
287300

@@ -459,6 +472,12 @@ impl<'a, T> RecvFut<'a, T> {
459472
}
460473
}
461474

475+
impl<'a, T> Debug for RecvFut<'a, T> {
476+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
477+
f.debug_struct("RecvFut").finish()
478+
}
479+
}
480+
462481
impl<'a, T> Drop for RecvFut<'a, T> {
463482
fn drop(&mut self) {
464483
self.reset_hook();
@@ -516,6 +535,12 @@ impl<'a, T> RecvStream<'a, T> {
516535
}
517536
}
518537

538+
impl<'a, T> Debug for RecvStream<'a, T> {
539+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
540+
f.debug_struct("RecvStream").finish()
541+
}
542+
}
543+
519544
impl<'a, T> Clone for RecvStream<'a, T> {
520545
fn clone(&self) -> RecvStream<'a, T> {
521546
RecvStream(RecvFut::new(self.0.receiver.clone()))

src/lib.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use std::{
4646
thread,
4747
fmt,
4848
};
49-
49+
use std::fmt::Formatter;
5050
#[cfg(feature = "spin")]
5151
use spin1::{Mutex as Spinlock, MutexGuard as SpinlockGuard};
5252
use crate::signal::{Signal, SyncSignal};
@@ -866,6 +866,12 @@ impl<T> WeakSender<T> {
866866
}
867867
}
868868

869+
impl<T> fmt::Debug for WeakSender<T> {
870+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
871+
f.debug_struct("WeakSender").finish()
872+
}
873+
}
874+
869875
impl<T> Clone for WeakSender<T> {
870876
/// Clones this [`WeakSender`].
871877
fn clone(&self) -> Self {
@@ -1041,6 +1047,12 @@ pub struct Iter<'a, T> {
10411047
receiver: &'a Receiver<T>,
10421048
}
10431049

1050+
impl<'a, T> fmt::Debug for Iter<'a, T> {
1051+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1052+
f.debug_struct("Iter").field("receiver", &self.receiver).finish()
1053+
}
1054+
}
1055+
10441056
impl<'a, T> Iterator for Iter<'a, T> {
10451057
type Item = T;
10461058

@@ -1054,6 +1066,12 @@ pub struct TryIter<'a, T> {
10541066
receiver: &'a Receiver<T>,
10551067
}
10561068

1069+
impl<'a, T> fmt::Debug for TryIter<'a, T> {
1070+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1071+
f.debug_struct("TryIter").field("receiver", &self.receiver).finish()
1072+
}
1073+
}
1074+
10571075
impl<'a, T> Iterator for TryIter<'a, T> {
10581076
type Item = T;
10591077

@@ -1091,6 +1109,12 @@ pub struct IntoIter<T> {
10911109
receiver: Receiver<T>,
10921110
}
10931111

1112+
impl<T> fmt::Debug for IntoIter<T> {
1113+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1114+
f.debug_struct("IntoIter").field("receiver", &self.receiver).finish()
1115+
}
1116+
}
1117+
10941118
impl<T> Iterator for IntoIter<T> {
10951119
type Item = T;
10961120

0 commit comments

Comments
 (0)