Skip to content

Commit

Permalink
Implement Debug for UdpSocket (#179)
Browse files Browse the repository at this point in the history
Allows structs that hold a socket to derive Debug automatically.
  • Loading branch information
progwriter committed Jul 23, 2024
1 parent e66ede2 commit 18ec30a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ pub struct UdpSocket {
rx: Mutex<Rx>,
}

impl std::fmt::Debug for UdpSocket {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("UdpSocket")
.field("local_addr", &self.local_addr)
.finish()
}
}

struct Rx {
recv: mpsc::Receiver<(Datagram, SocketAddr)>,
/// A buffered received message.
Expand Down

0 comments on commit 18ec30a

Please sign in to comment.