Skip to content

Commit 02cb854

Browse files
Alexander Polakovkamalmarhubi
Alexander Polakov
authored andcommitted
Derive all the things
as suggested by @kamalmarhubi
1 parent b45c505 commit 02cb854

File tree

2 files changed

+4
-25
lines changed

2 files changed

+4
-25
lines changed

src/sys/socket/addr.rs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use ::sys::socket::addr::netlink::NetlinkAddr;
1717
*/
1818

1919
#[cfg(any(target_os = "linux", target_os = "android"))]
20-
#[derive(Debug,Copy,Clone)]
20+
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
2121
#[repr(C)]
2222
pub struct sockaddr_nl {
2323
pub nl_family: sa_family_t,
@@ -560,9 +560,9 @@ impl fmt::Display for SockAddr {
560560
pub mod netlink {
561561
use ::sys::socket::addr::{AddressFamily,sockaddr_nl};
562562
use libc::sa_family_t;
563-
use std::{fmt, hash};
563+
use std::fmt;
564564

565-
#[derive(Copy)]
565+
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
566566
pub struct NetlinkAddr(pub sockaddr_nl);
567567

568568
impl NetlinkAddr {
@@ -584,27 +584,6 @@ pub mod netlink {
584584
}
585585
}
586586

587-
impl PartialEq for NetlinkAddr {
588-
fn eq(&self, other: &NetlinkAddr) -> bool {
589-
self.0.nl_pid == other.0.nl_pid && self.0.nl_groups == self.0.nl_groups
590-
}
591-
}
592-
593-
impl Eq for NetlinkAddr {
594-
}
595-
596-
impl hash::Hash for NetlinkAddr {
597-
fn hash<H: hash::Hasher>(&self, s: &mut H) {
598-
( self.0.nl_family, self.0.nl_pid, self.0.nl_groups).hash(s)
599-
}
600-
}
601-
602-
impl Clone for NetlinkAddr {
603-
fn clone(&self) -> NetlinkAddr {
604-
*self
605-
}
606-
}
607-
608587
impl fmt::Display for NetlinkAddr {
609588
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
610589
write!(f, "pid: {} groups: {}", self.pid(), self.groups())

src/sys/socket/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ pub enum SockLevel {
541541
Ip = IPPROTO_IP,
542542
Ipv6 = IPPROTO_IPV6,
543543
Udp = IPPROTO_UDP,
544-
#[cfg(any(target_os = "linux", target_os = "android"))]
544+
#[cfg(any(target_os = "linux", target_os = "android"))]
545545
Netlink = SOL_NETLINK,
546546
}
547547

0 commit comments

Comments
 (0)