Skip to content

Commit c1d64a0

Browse files
Add missing impl Debug
1 parent db79b05 commit c1d64a0

File tree

4 files changed

+57
-5
lines changed

4 files changed

+57
-5
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ tokio = ["dep:tokio"]
1515
[dependencies]
1616
futures = "0.3"
1717
log = "0.4"
18-
tokio = { version = "1.48", optional = true, features = ["time"] }
18+
tokio = { version = "1.50", optional = true, features = ["time"] }
1919

2020
[dev-dependencies]
2121
static_assertions = "1.1"
2222
tokio-test = "0.4"
23-
tokio = { version = "1.48", features = ["time", "io-util"] }
23+
tokio = { version = "1.50", features = ["time", "io-util"] }
2424

2525
[profile.dev]
2626
opt-level = 3

src/shared/local_shared.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::{Shared, UnsafeShared};
22
use std::cell::{RefCell, UnsafeCell};
3+
use std::fmt;
34
use std::rc::Rc;
45

56
/// Non-Send wrapper that allows access to the underlying data only through the `Shared` interface.
@@ -23,6 +24,12 @@ impl<T> Shared for LocalShared<T> {
2324
}
2425
}
2526

27+
impl<T: fmt::Debug> fmt::Debug for LocalShared<T> {
28+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29+
f.debug_tuple("LocalShared").field(&self.0.borrow()).finish()
30+
}
31+
}
32+
2633
impl<T> Clone for LocalShared<T> {
2734
fn clone(&self) -> Self {
2835
Self(self.0.clone())
@@ -50,6 +57,13 @@ impl<T> UnsafeShared for LocalUnsafeShared<T> {
5057
}
5158
}
5259

60+
impl<T: fmt::Debug> fmt::Debug for LocalUnsafeShared<T> {
61+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
62+
let value = unsafe { &*self.0.get() };
63+
f.debug_tuple("LocalUnsafeShared").field(value).finish()
64+
}
65+
}
66+
5367
impl<T> Clone for LocalUnsafeShared<T> {
5468
fn clone(&self) -> Self {
5569
Self(self.0.clone())

src/split.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//! Utilities for splitting `AsyncRead + AsyncWrite` types into separate read and write halves.
22
33
use std::cell::RefCell;
4-
use std::io;
54
use std::pin::Pin;
65
use std::rc::Rc;
76
use std::task::{Context, Poll};
7+
use std::{fmt, io};
88
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
99

1010
/// The readable half of a value returned from [`split`].
@@ -68,3 +68,15 @@ impl<T: AsyncWrite> AsyncWrite for WriteHalf<T> {
6868
self.0.borrow().is_write_vectored()
6969
}
7070
}
71+
72+
impl<T: fmt::Debug + AsyncRead> fmt::Debug for ReadHalf<T> {
73+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
74+
f.debug_tuple("ReadHalf").finish()
75+
}
76+
}
77+
78+
impl<T: fmt::Debug + AsyncWrite> fmt::Debug for WriteHalf<T> {
79+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
80+
f.debug_tuple("WriteHalf").finish()
81+
}
82+
}

src/sync/pipe.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ use std::cell::UnsafeCell;
33
use std::io::BufRead;
44
use std::rc::Rc;
55
use std::task::{Context, Poll, Waker};
6-
use std::{cmp, io};
6+
use std::{cmp, fmt, io};
77
use std::{collections::VecDeque, pin::Pin};
88
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
99

1010
/// Unidirectional in-memory pipe implementing `AsyncRead` and `AsyncWrite`.
1111
/// A more efficient version of [`tokio::io::SimplexStream`](https://docs.rs/tokio/latest/tokio/io/struct.SimplexStream.html)
1212
/// optimized for single-threaded use cases.
13-
#[derive(Debug)]
1413
pub struct Pipe {
1514
buffer: VecDeque<u8>,
1615
is_closed: bool,
@@ -180,6 +179,15 @@ impl AsyncWrite for Pipe {
180179
}
181180
}
182181

182+
impl fmt::Debug for Pipe {
183+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
184+
f.debug_struct("Pipe")
185+
.field("buffer_len", &self.buffer.len())
186+
.field("is_closed", &self.is_closed)
187+
.finish()
188+
}
189+
}
190+
183191
/// The readable end of a [`Pipe`]. Not thread-safe.
184192
pub struct ReadEnd(Rc<UnsafeCell<Pipe>>);
185193

@@ -204,6 +212,12 @@ impl Drop for ReadEnd {
204212
}
205213
}
206214

215+
impl fmt::Debug for ReadEnd {
216+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
217+
f.debug_tuple("ReadEnd").finish()
218+
}
219+
}
220+
207221
impl AsyncWrite for WriteEnd {
208222
fn poll_write(
209223
mut self: Pin<&mut Self>,
@@ -248,6 +262,12 @@ impl Drop for WriteEnd {
248262
}
249263
}
250264

265+
impl fmt::Debug for WriteEnd {
266+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
267+
f.debug_tuple("WriteEnd").finish()
268+
}
269+
}
270+
251271
/// Create a bi-directional in-memory stream of bytes using two [`Pipe`]s in opposite directions.
252272
/// Non-thread-safe equivalent of [`tokio::io::duplex`](https://docs.rs/tokio/latest/tokio/io/fn.duplex.html).
253273
/// # Returns
@@ -322,6 +342,12 @@ impl AsyncWrite for DuplexEnd {
322342
}
323343
}
324344

345+
impl fmt::Debug for DuplexEnd {
346+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
347+
f.debug_tuple("DuplexEnd").finish()
348+
}
349+
}
350+
325351
#[cfg(test)]
326352
mod tests {
327353
use super::*;

0 commit comments

Comments
 (0)