Skip to content

Commit 780b96d

Browse files
committed
Implement Debug for cap_std::net::TcpListener.
1 parent 3e4bcee commit 780b96d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cap-std/src/net/tcp_listener.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::net::{Incoming, SocketAddr, TcpStream};
33
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
44
#[cfg(windows)]
55
use std::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket};
6-
use std::{io, net};
6+
use std::{fmt, io, net};
77

88
/// A TCP socket server, listening for connections.
99
///
@@ -158,4 +158,10 @@ impl IntoRawSocket for TcpListener {
158158
}
159159
}
160160

161-
// TODO: impl Debug for TcpListener
161+
impl fmt::Debug for TcpListener {
162+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
163+
// Don't leak the address/port.
164+
let mut res = f.debug_struct("TcpListener");
165+
res.finish()
166+
}
167+
}

0 commit comments

Comments
 (0)