Skip to content

Commit b091f20

Browse files
Alexander Polakovroot
Alexander Polakov
authored and
root
committed
Derive all the things
as suggested by @kamalmarhubi
1 parent 699285e commit b091f20

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
@@ -18,7 +18,7 @@ use ::sys::socket::addr::netlink::NetlinkAddr;
1818
*/
1919

2020
#[cfg(any(target_os = "linux", target_os = "android"))]
21-
#[derive(Debug,Copy,Clone)]
21+
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
2222
#[repr(C)]
2323
pub struct sockaddr_nl {
2424
pub nl_family: sa_family_t,
@@ -557,9 +557,9 @@ impl fmt::Display for SockAddr {
557557
pub mod netlink {
558558
use ::sys::socket::addr::{AddressFamily,sockaddr_nl};
559559
use libc::sa_family_t;
560-
use std::{fmt, hash};
560+
use std::fmt;
561561

562-
#[derive(Copy)]
562+
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
563563
pub struct NetlinkAddr(pub sockaddr_nl);
564564

565565
impl NetlinkAddr {
@@ -581,27 +581,6 @@ pub mod netlink {
581581
}
582582
}
583583

584-
impl PartialEq for NetlinkAddr {
585-
fn eq(&self, other: &NetlinkAddr) -> bool {
586-
self.0.nl_pid == other.0.nl_pid && self.0.nl_groups == self.0.nl_groups
587-
}
588-
}
589-
590-
impl Eq for NetlinkAddr {
591-
}
592-
593-
impl hash::Hash for NetlinkAddr {
594-
fn hash<H: hash::Hasher>(&self, s: &mut H) {
595-
( self.0.nl_family, self.0.nl_pid, self.0.nl_groups).hash(s)
596-
}
597-
}
598-
599-
impl Clone for NetlinkAddr {
600-
fn clone(&self) -> NetlinkAddr {
601-
*self
602-
}
603-
}
604-
605584
impl fmt::Display for NetlinkAddr {
606585
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
607586
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
@@ -601,7 +601,7 @@ pub enum SockLevel {
601601
Ip = IPPROTO_IP,
602602
Ipv6 = IPPROTO_IPV6,
603603
Udp = IPPROTO_UDP,
604-
#[cfg(any(target_os = "linux", target_os = "android"))]
604+
#[cfg(any(target_os = "linux", target_os = "android"))]
605605
Netlink = SOL_NETLINK,
606606
}
607607

0 commit comments

Comments
 (0)