@@ -6,6 +6,7 @@ use get_thread_id;
6
6
use glib_sys;
7
7
use std:: cell:: RefCell ;
8
8
use std:: collections:: VecDeque ;
9
+ use std:: fmt;
9
10
use std:: mem;
10
11
use std:: ptr;
11
12
use std:: sync:: mpsc;
@@ -17,7 +18,6 @@ use Priority;
17
18
use Source ;
18
19
use SourceId ;
19
20
20
- #[ derive( Debug ) ]
21
21
enum ChannelSourceState {
22
22
NotAttached ,
23
23
Attached ( * mut glib_sys:: GSource ) ,
@@ -27,7 +27,6 @@ enum ChannelSourceState {
27
27
unsafe impl Send for ChannelSourceState { }
28
28
unsafe impl Sync for ChannelSourceState { }
29
29
30
- #[ derive( Debug ) ]
31
30
struct ChannelInner < T > {
32
31
queue : VecDeque < T > ,
33
32
source : ChannelSourceState ,
@@ -71,13 +70,11 @@ impl<T> ChannelInner<T> {
71
70
}
72
71
}
73
72
74
- #[ derive( Debug ) ]
75
73
struct ChannelBound {
76
74
bound : usize ,
77
75
cond : Condvar ,
78
76
}
79
77
80
- #[ derive( Debug ) ]
81
78
struct Channel < T > ( Arc < ( Mutex < ChannelInner < T > > , Option < ChannelBound > ) > ) ;
82
79
83
80
impl < T > Clone for Channel < T > {
@@ -321,9 +318,20 @@ unsafe extern "C" fn finalize<T, F: FnMut(T) -> Continue + 'static>(
321
318
/// See [`MainContext::channel()`] for how to create such a `Sender`.
322
319
///
323
320
/// [`MainContext::channel()`]: struct.MainContext.html#method.channel
324
- #[ derive( Clone , Debug ) ]
325
321
pub struct Sender < T > ( Option < Channel < T > > ) ;
326
322
323
+ impl < T > fmt:: Debug for Sender < T > {
324
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
325
+ f. debug_struct ( "Sender" ) . finish ( )
326
+ }
327
+ }
328
+
329
+ impl < T > Clone for Sender < T > {
330
+ fn clone ( & self ) -> Sender < T > {
331
+ Sender ( self . 0 . clone ( ) )
332
+ }
333
+ }
334
+
327
335
impl < T > Sender < T > {
328
336
/// Sends a value to the channel.
329
337
pub fn send ( & self , t : T ) -> Result < ( ) , mpsc:: SendError < T > > {
@@ -363,9 +371,20 @@ impl<T> Drop for Sender<T> {
363
371
/// See [`MainContext::sync_channel()`] for how to create such a `SyncSender`.
364
372
///
365
373
/// [`MainContext::sync_channel()`]: struct.MainContext.html#method.sync_channel
366
- #[ derive( Clone , Debug ) ]
367
374
pub struct SyncSender < T > ( Option < Channel < T > > ) ;
368
375
376
+ impl < T > fmt:: Debug for SyncSender < T > {
377
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
378
+ f. debug_struct ( "SyncSender" ) . finish ( )
379
+ }
380
+ }
381
+
382
+ impl < T > Clone for SyncSender < T > {
383
+ fn clone ( & self ) -> SyncSender < T > {
384
+ SyncSender ( self . 0 . clone ( ) )
385
+ }
386
+ }
387
+
369
388
impl < T > SyncSender < T > {
370
389
/// Sends a value to the channel and blocks if the channel is full.
371
390
pub fn send ( & self , t : T ) -> Result < ( ) , mpsc:: SendError < T > > {
@@ -411,9 +430,14 @@ impl<T> Drop for SyncSender<T> {
411
430
///
412
431
/// [`MainContext::channel()`]: struct.MainContext.html#method.channel
413
432
/// [`MainContext::sync_channel()`]: struct.MainContext.html#method.sync_channel
414
- #[ derive( Debug ) ]
415
433
pub struct Receiver < T > ( Option < Channel < T > > , Priority ) ;
416
434
435
+ impl < T > fmt:: Debug for Receiver < T > {
436
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
437
+ f. debug_struct ( "Receiver" ) . finish ( )
438
+ }
439
+ }
440
+
417
441
// It's safe to send the Receiver to other threads for attaching it as
418
442
// long as the items to be sent can also be sent between threads.
419
443
unsafe impl < T : Send > Send for Receiver < T > { }
0 commit comments