diff options
author | Alexander Polakov <apolyakov@beget.ru> | 2016-01-27 01:47:34 +0300 |
---|---|---|
committer | Kamal Marhubi <kamal@marhubi.com> | 2016-01-28 10:33:44 -0500 |
commit | 02cb854372c8f893b53f65023da0bf57a7be4a76 (patch) | |
tree | 08077a743793906d2b05c8ba9adf12532b655193 /src/sys/socket/addr.rs | |
parent | b45c505dd8f1c50ba24621481c8025355ba23908 (diff) | |
download | nix-02cb854372c8f893b53f65023da0bf57a7be4a76.zip |
Derive all the things
as suggested by @kamalmarhubi
Diffstat (limited to 'src/sys/socket/addr.rs')
-rw-r--r-- | src/sys/socket/addr.rs | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index 8494632f..5f9f947e 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -17,7 +17,7 @@ use ::sys::socket::addr::netlink::NetlinkAddr; */ #[cfg(any(target_os = "linux", target_os = "android"))] -#[derive(Debug,Copy,Clone)] +#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] #[repr(C)] pub struct sockaddr_nl { pub nl_family: sa_family_t, @@ -560,9 +560,9 @@ impl fmt::Display for SockAddr { pub mod netlink { use ::sys::socket::addr::{AddressFamily,sockaddr_nl}; use libc::sa_family_t; - use std::{fmt, hash}; + use std::fmt; - #[derive(Copy)] + #[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] pub struct NetlinkAddr(pub sockaddr_nl); impl NetlinkAddr { @@ -584,27 +584,6 @@ pub mod netlink { } } - impl PartialEq for NetlinkAddr { - fn eq(&self, other: &NetlinkAddr) -> bool { - self.0.nl_pid == other.0.nl_pid && self.0.nl_groups == self.0.nl_groups - } - } - - impl Eq for NetlinkAddr { - } - - impl hash::Hash for NetlinkAddr { - fn hash<H: hash::Hasher>(&self, s: &mut H) { - ( self.0.nl_family, self.0.nl_pid, self.0.nl_groups).hash(s) - } - } - - impl Clone for NetlinkAddr { - fn clone(&self) -> NetlinkAddr { - *self - } - } - impl fmt::Display for NetlinkAddr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "pid: {} groups: {}", self.pid(), self.groups()) |