diff --git a/src/ifaddrs.rs b/src/ifaddrs.rs index 2b3024b54a..61d36ff4cd 100644 --- a/src/ifaddrs.rs +++ b/src/ifaddrs.rs @@ -4,7 +4,6 @@ //! of interfaces and their associated addresses. use std::ffi; -use std::fmt; use std::iter::Iterator; use std::mem; use std::option::Option; @@ -16,7 +15,7 @@ use sys::socket::SockAddr; use net::if_::*; /// Describes a single address for an interface as returned by `getifaddrs`. -#[derive(Clone, Eq, Hash, PartialEq)] +#[derive(Clone, Eq, Hash, PartialEq, Debug)] pub struct InterfaceAddress { /// Name of the network interface pub interface_name: String, @@ -32,12 +31,6 @@ pub struct InterfaceAddress { pub destination: Option, } -impl fmt::Debug for InterfaceAddress { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "InterfaceAddress ({:?})", self.interface_name) - } -} - cfg_if! { if #[cfg(any(target_os = "emscripten", target_os = "fuchsia", target_os = "linux"))] { fn get_ifu_from_sockaddr(info: &libc::ifaddrs) -> *const libc::sockaddr { diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index dd2ae17d32..445fb9ef5c 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -357,6 +357,12 @@ impl fmt::Display for InetAddr { } } +impl fmt::Debug for InetAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + /* * * ===== IpAddr ===== @@ -409,6 +415,12 @@ impl fmt::Display for IpAddr { } } +impl fmt::Debug for IpAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + /* * * ===== Ipv4Addr ===== @@ -470,6 +482,12 @@ impl fmt::Display for Ipv4Addr { } } +impl fmt::Debug for Ipv4Addr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + /* * * ===== Ipv6Addr ===== @@ -524,6 +542,12 @@ impl fmt::Display for Ipv6Addr { } } +impl fmt::Debug for Ipv6Addr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + /* * * ===== UnixAddr ===== @@ -658,6 +682,12 @@ impl fmt::Display for UnixAddr { } } +impl fmt::Debug for UnixAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } +} + /* * * ===== Sock addr ===== @@ -850,6 +880,12 @@ pub mod netlink { write!(f, "pid: {} groups: {}", self.pid(), self.groups()) } } + + impl fmt::Debug for NetlinkAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } + } } #[cfg(any(target_os = "ios", target_os = "macos"))] @@ -948,4 +984,10 @@ pub mod sys_control { write!(f, "id: {} unit: {}", self.id(), self.unit()) } } + + impl fmt::Debug for SysControlAddr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self, f) + } + } }