diff options
| author | bors <bors@rust-lang.org> | 2016-01-20 03:28:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-01-20 03:28:54 +0000 |
| commit | 7561466948727be1ce20a7e349b53b6d0f86dbe9 (patch) | |
| tree | 4a8ba1b959c57a4c8af31ea43159dd84cd54d2ed /src/libstd/sync/mpsc/mod.rs | |
| parent | 2bd875d3d4a9f06a4a18325d6e4a68b5234a09f6 (diff) | |
| parent | 0e3fb184ed1cf269ec04531c2750d9cce4c034bd (diff) | |
| download | rust-7561466948727be1ce20a7e349b53b6d0f86dbe9.tar.gz rust-7561466948727be1ce20a7e349b53b6d0f86dbe9.zip | |
Auto merge of #30894 - antrik:debug-mpsc, r=brson
Minimal fix for https://github.com/rust-lang/rust/issues/30563 This covers all the public structs I think; except for Iter and IntoIter, which I don't know if or how they should be handled.
Diffstat (limited to 'src/libstd/sync/mpsc/mod.rs')
| -rw-r--r-- | src/libstd/sync/mpsc/mod.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 3eb5db09bc0..64230c9e016 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -635,6 +635,13 @@ impl<T> Drop for Sender<T> { } } +#[stable(feature = "mpsc_debug", since = "1.7.0")] +impl<T> fmt::Debug for Sender<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Sender {{ .. }}") + } +} + //////////////////////////////////////////////////////////////////////////////// // SyncSender //////////////////////////////////////////////////////////////////////////////// @@ -693,6 +700,13 @@ impl<T> Drop for SyncSender<T> { } } +#[stable(feature = "mpsc_debug", since = "1.7.0")] +impl<T> fmt::Debug for SyncSender<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "SyncSender {{ .. }}") + } +} + //////////////////////////////////////////////////////////////////////////////// // Receiver //////////////////////////////////////////////////////////////////////////////// @@ -987,6 +1001,13 @@ impl<T> Drop for Receiver<T> { } } +#[stable(feature = "mpsc_debug", since = "1.7.0")] +impl<T> fmt::Debug for Receiver<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Receiver {{ .. }}") + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl<T> fmt::Debug for SendError<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -2199,4 +2220,22 @@ mod sync_tests { repro() } } + + #[test] + fn fmt_debug_sender() { + let (tx, _) = channel::<i32>(); + assert_eq!(format!("{:?}", tx), "Sender { .. }"); + } + + #[test] + fn fmt_debug_recv() { + let (_, rx) = channel::<i32>(); + assert_eq!(format!("{:?}", rx), "Receiver { .. }"); + } + + #[test] + fn fmt_debug_sync_sender() { + let (tx, _) = sync_channel::<i32>(1); + assert_eq!(format!("{:?}", tx), "SyncSender { .. }"); + } } |
