@@ -4,22 +4,28 @@ use std::error::Error;
44use std:: fmt;
55
66/// Error returned by the `Sender`.
7- #[ derive( Debug ) ]
7+ #[ derive( PartialEq , Eq , Clone , Copy ) ]
88pub struct SendError < T > ( pub T ) ;
99
10+ impl < T > fmt:: Debug for SendError < T > {
11+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
12+ f. debug_struct ( "SendError" ) . finish_non_exhaustive ( )
13+ }
14+ }
15+
1016impl < T > fmt:: Display for SendError < T > {
1117 fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1218 write ! ( fmt, "channel closed" )
1319 }
1420}
1521
16- impl < T : fmt :: Debug > std:: error:: Error for SendError < T > { }
22+ impl < T > std:: error:: Error for SendError < T > { }
1723
1824// ===== TrySendError =====
1925
2026/// This enumeration is the list of the possible error outcomes for the
2127/// [try_send](super::Sender::try_send) method.
22- #[ derive( Debug , Eq , PartialEq ) ]
28+ #[ derive( PartialEq , Eq , Clone , Copy ) ]
2329pub enum TrySendError < T > {
2430 /// The data could not be sent on the channel because the channel is
2531 /// currently full and sending would require blocking.
@@ -30,7 +36,14 @@ pub enum TrySendError<T> {
3036 Closed ( T ) ,
3137}
3238
33- impl < T : fmt:: Debug > Error for TrySendError < T > { }
39+ impl < T > fmt:: Debug for TrySendError < T > {
40+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
41+ match * self {
42+ TrySendError :: Full ( ..) => "Full(..)" . fmt ( f) ,
43+ TrySendError :: Closed ( ..) => "Closed(..)" . fmt ( f) ,
44+ }
45+ }
46+ }
3447
3548impl < T > fmt:: Display for TrySendError < T > {
3649 fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -45,6 +58,8 @@ impl<T> fmt::Display for TrySendError<T> {
4558 }
4659}
4760
61+ impl < T > Error for TrySendError < T > { }
62+
4863impl < T > From < SendError < T > > for TrySendError < T > {
4964 fn from ( src : SendError < T > ) -> TrySendError < T > {
5065 TrySendError :: Closed ( src. 0 )
@@ -96,7 +111,7 @@ impl Error for RecvError {}
96111cfg_time ! {
97112 // ===== SendTimeoutError =====
98113
99- #[ derive( Debug , Eq , PartialEq ) ]
114+ #[ derive( PartialEq , Eq , Clone , Copy ) ]
100115 /// Error returned by [`Sender::send_timeout`](super::Sender::send_timeout)].
101116 pub enum SendTimeoutError <T > {
102117 /// The data could not be sent on the channel because the channel is
@@ -108,7 +123,14 @@ cfg_time! {
108123 Closed ( T ) ,
109124 }
110125
111- impl <T : fmt:: Debug > Error for SendTimeoutError <T > { }
126+ impl <T > fmt:: Debug for SendTimeoutError <T > {
127+ fn fmt( & self , f: & mut fmt:: Formatter <' _>) -> fmt:: Result {
128+ match * self {
129+ SendTimeoutError :: Timeout ( ..) => "Timeout(..)" . fmt( f) ,
130+ SendTimeoutError :: Closed ( ..) => "Closed(..)" . fmt( f) ,
131+ }
132+ }
133+ }
112134
113135 impl <T > fmt:: Display for SendTimeoutError <T > {
114136 fn fmt( & self , fmt: & mut fmt:: Formatter <' _>) -> fmt:: Result {
@@ -122,4 +144,6 @@ cfg_time! {
122144 )
123145 }
124146 }
147+
148+ impl <T > Error for SendTimeoutError <T > { }
125149}
0 commit comments