Skip to content

Commit 4a6d93f

Browse files
committed
WIP: Use derived traits in more places
1 parent 0607c09 commit 4a6d93f

File tree

1 file changed

+8
-369
lines changed

1 file changed

+8
-369
lines changed

src/unix/bsd/apple/mod.rs

Lines changed: 8 additions & 369 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,14 +1250,6 @@ s! {
12501250
pub proc_fd: i32,
12511251
pub proc_fdtype: u32,
12521252
}
1253-
}
1254-
1255-
s_no_extra_traits! {
1256-
#[repr(packed(4))]
1257-
pub struct ifconf {
1258-
pub ifc_len: c_int,
1259-
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
1260-
}
12611253

12621254
#[repr(packed(4))]
12631255
pub struct kevent {
@@ -1380,6 +1372,14 @@ s_no_extra_traits! {
13801372
__unused1: *mut c_void, //actually a function pointer
13811373
pub sigev_notify_attributes: *mut crate::pthread_attr_t,
13821374
}
1375+
}
1376+
1377+
s_no_extra_traits! {
1378+
#[repr(packed(4))]
1379+
pub struct ifconf {
1380+
pub ifc_len: c_int,
1381+
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
1382+
}
13831383

13841384
pub struct processor_cpu_load_info {
13851385
pub cpu_ticks: [c_uint; CPU_STATE_MAX as usize],
@@ -1674,367 +1674,6 @@ cfg_if! {
16741674

16751675
cfg_if! {
16761676
if #[cfg(feature = "extra_traits")] {
1677-
impl PartialEq for kevent {
1678-
fn eq(&self, other: &kevent) -> bool {
1679-
self.ident == other.ident
1680-
&& self.filter == other.filter
1681-
&& self.flags == other.flags
1682-
&& self.fflags == other.fflags
1683-
&& self.data == other.data
1684-
&& self.udata == other.udata
1685-
}
1686-
}
1687-
impl Eq for kevent {}
1688-
impl hash::Hash for kevent {
1689-
fn hash<H: hash::Hasher>(&self, state: &mut H) {
1690-
let ident = self.ident;
1691-
let filter = self.filter;
1692-
let flags = self.flags;
1693-
let fflags = self.fflags;
1694-
let data = self.data;
1695-
let udata = self.udata;
1696-
ident.hash(state);
1697-
filter.hash(state);
1698-
flags.hash(state);
1699-
fflags.hash(state);
1700-
data.hash(state);
1701-
udata.hash(state);
1702-
}
1703-
}
1704-
1705-
impl PartialEq for semid_ds {
1706-
fn eq(&self, other: &semid_ds) -> bool {
1707-
let sem_perm = self.sem_perm;
1708-
let sem_pad3 = self.sem_pad3;
1709-
let other_sem_perm = other.sem_perm;
1710-
let other_sem_pad3 = other.sem_pad3;
1711-
sem_perm == other_sem_perm
1712-
&& self.sem_base == other.sem_base
1713-
&& self.sem_nsems == other.sem_nsems
1714-
&& self.sem_otime == other.sem_otime
1715-
&& self.sem_pad1 == other.sem_pad1
1716-
&& self.sem_ctime == other.sem_ctime
1717-
&& self.sem_pad2 == other.sem_pad2
1718-
&& sem_pad3 == other_sem_pad3
1719-
}
1720-
}
1721-
impl Eq for semid_ds {}
1722-
impl hash::Hash for semid_ds {
1723-
fn hash<H: hash::Hasher>(&self, state: &mut H) {
1724-
let sem_perm = self.sem_perm;
1725-
let sem_base = self.sem_base;
1726-
let sem_nsems = self.sem_nsems;
1727-
let sem_otime = self.sem_otime;
1728-
let sem_pad1 = self.sem_pad1;
1729-
let sem_ctime = self.sem_ctime;
1730-
let sem_pad2 = self.sem_pad2;
1731-
let sem_pad3 = self.sem_pad3;
1732-
sem_perm.hash(state);
1733-
sem_base.hash(state);
1734-
sem_nsems.hash(state);
1735-
sem_otime.hash(state);
1736-
sem_pad1.hash(state);
1737-
sem_ctime.hash(state);
1738-
sem_pad2.hash(state);
1739-
sem_pad3.hash(state);
1740-
}
1741-
}
1742-
1743-
impl PartialEq for shmid_ds {
1744-
fn eq(&self, other: &shmid_ds) -> bool {
1745-
let shm_perm = self.shm_perm;
1746-
let other_shm_perm = other.shm_perm;
1747-
shm_perm == other_shm_perm
1748-
&& self.shm_segsz == other.shm_segsz
1749-
&& self.shm_lpid == other.shm_lpid
1750-
&& self.shm_cpid == other.shm_cpid
1751-
&& self.shm_nattch == other.shm_nattch
1752-
&& self.shm_atime == other.shm_atime
1753-
&& self.shm_dtime == other.shm_dtime
1754-
&& self.shm_ctime == other.shm_ctime
1755-
&& self.shm_internal == other.shm_internal
1756-
}
1757-
}
1758-
impl Eq for shmid_ds {}
1759-
impl hash::Hash for shmid_ds {
1760-
fn hash<H: hash::Hasher>(&self, state: &mut H) {
1761-
let shm_perm = self.shm_perm;
1762-
let shm_segsz = self.shm_segsz;
1763-
let shm_lpid = self.shm_lpid;
1764-
let shm_cpid = self.shm_cpid;
1765-
let shm_nattch = self.shm_nattch;
1766-
let shm_atime = self.shm_atime;
1767-
let shm_dtime = self.shm_dtime;
1768-
let shm_ctime = self.shm_ctime;
1769-
let shm_internal = self.shm_internal;
1770-
shm_perm.hash(state);
1771-
shm_segsz.hash(state);
1772-
shm_lpid.hash(state);
1773-
shm_cpid.hash(state);
1774-
shm_nattch.hash(state);
1775-
shm_atime.hash(state);
1776-
shm_dtime.hash(state);
1777-
shm_ctime.hash(state);
1778-
shm_internal.hash(state);
1779-
}
1780-
}
1781-
1782-
impl PartialEq for proc_threadinfo {
1783-
fn eq(&self, other: &proc_threadinfo) -> bool {
1784-
self.pth_user_time == other.pth_user_time
1785-
&& self.pth_system_time == other.pth_system_time
1786-
&& self.pth_cpu_usage == other.pth_cpu_usage
1787-
&& self.pth_policy == other.pth_policy
1788-
&& self.pth_run_state == other.pth_run_state
1789-
&& self.pth_flags == other.pth_flags
1790-
&& self.pth_sleep_time == other.pth_sleep_time
1791-
&& self.pth_curpri == other.pth_curpri
1792-
&& self.pth_priority == other.pth_priority
1793-
&& self.pth_maxpriority == other.pth_maxpriority
1794-
&& self
1795-
.pth_name
1796-
.iter()
1797-
.zip(other.pth_name.iter())
1798-
.all(|(a, b)| a == b)
1799-
}
1800-
}
1801-
impl Eq for proc_threadinfo {}
1802-
impl hash::Hash for proc_threadinfo {
1803-
fn hash<H: hash::Hasher>(&self, state: &mut H) {
1804-
self.pth_user_time.hash(state);
1805-
self.pth_system_time.hash(state);
1806-
self.pth_cpu_usage.hash(state);
1807-
self.pth_policy.hash(state);
1808-
self.pth_run_state.hash(state);
1809-
self.pth_flags.hash(state);
1810-
self.pth_sleep_time.hash(state);
1811-
self.pth_curpri.hash(state);
1812-
self.pth_priority.hash(state);
1813-
self.pth_maxpriority.hash(state);
1814-
self.pth_name.hash(state);
1815-
}
1816-
}
1817-
1818-
impl PartialEq for statfs {
1819-
fn eq(&self, other: &statfs) -> bool {
1820-
self.f_bsize == other.f_bsize
1821-
&& self.f_iosize == other.f_iosize
1822-
&& self.f_blocks == other.f_blocks
1823-
&& self.f_bfree == other.f_bfree
1824-
&& self.f_bavail == other.f_bavail
1825-
&& self.f_files == other.f_files
1826-
&& self.f_ffree == other.f_ffree
1827-
&& self.f_fsid == other.f_fsid
1828-
&& self.f_owner == other.f_owner
1829-
&& self.f_flags == other.f_flags
1830-
&& self.f_fssubtype == other.f_fssubtype
1831-
&& self.f_fstypename == other.f_fstypename
1832-
&& self.f_type == other.f_type
1833-
&& self
1834-
.f_mntonname
1835-
.iter()
1836-
.zip(other.f_mntonname.iter())
1837-
.all(|(a, b)| a == b)
1838-
&& self
1839-
.f_mntfromname
1840-
.iter()
1841-
.zip(other.f_mntfromname.iter())
1842-
.all(|(a, b)| a == b)
1843-
&& self.f_reserved == other.f_reserved
1844-
}
1845-
}
1846-
1847-
impl Eq for statfs {}
1848-
1849-
impl hash::Hash for statfs {
1850-
fn hash<H: hash::Hasher>(&self, state: &mut H) {
1851-
self.f_bsize.hash(state);
1852-
self.f_iosize.hash(state);
1853-
self.f_blocks.hash(state);
1854-
self.f_bfree.hash(state);
1855-
self.f_bavail.hash(state);
1856-
self.f_files.hash(state);
1857-
self.f_ffree.hash(state);
1858-
self.f_fsid.hash(state);
1859-
self.f_owner.hash(state);
1860-
self.f_flags.hash(state);
1861-
self.f_fssubtype.hash(state);
1862-
self.f_fstypename.hash(state);
1863-
self.f_type.hash(state);
1864-
self.f_mntonname.hash(state);
1865-
self.f_mntfromname.hash(state);
1866-
self.f_reserved.hash(state);
1867-
}
1868-
}
1869-
1870-
impl PartialEq for dirent {
1871-
fn eq(&self, other: &dirent) -> bool {
1872-
self.d_ino == other.d_ino
1873-
&& self.d_seekoff == other.d_seekoff
1874-
&& self.d_reclen == other.d_reclen
1875-
&& self.d_namlen == other.d_namlen
1876-
&& self.d_type == other.d_type
1877-
&& self
1878-
.d_name
1879-
.iter()
1880-
.zip(other.d_name.iter())
1881-
.all(|(a, b)| a == b)
1882-
}
1883-
}
1884-
impl Eq for dirent {}
1885-
impl hash::Hash for dirent {
1886-
fn hash<H: hash::Hasher>(&self, state: &mut H) {
1887-
self.d_ino.hash(state);
1888-
self.d_seekoff.hash(state);
1889-
self.d_reclen.hash(state);
1890-
self.d_namlen.hash(state);
1891-
self.d_type.hash(state);
1892-
self.d_name.hash(state);
1893-
}
1894-
}
1895-
impl PartialEq for pthread_rwlock_t {
1896-
fn eq(&self, other: &pthread_rwlock_t) -> bool {
1897-
self.__sig == other.__sig
1898-
&& self
1899-
.__opaque
1900-
.iter()
1901-
.zip(other.__opaque.iter())
1902-
.all(|(a, b)| a == b)
1903-
}
1904-
}
1905-
impl Eq for pthread_rwlock_t {}
1906-
impl hash::Hash for pthread_rwlock_t {
1907-
fn hash<H: hash::Hasher>(&self, state: &mut H) {
1908-
self.__sig.hash(state);
1909-
self.__opaque.hash(state);
1910-
}
1911-
}
1912-
1913-
impl PartialEq for pthread_mutex_t {
1914-
fn eq(&self, other: &pthread_mutex_t) -> bool {
1915-
self.__sig == other.__sig
1916-
&& self
1917-
.__opaque
1918-
.iter()
1919-
.zip(other.__opaque.iter())
1920-
.all(|(a, b)| a == b)
1921-
}
1922-
}
1923-
1924-
impl Eq for pthread_mutex_t {}
1925-
1926-
impl hash::Hash for pthread_mutex_t {
1927-
fn hash<H: hash::Hasher>(&self, state: &mut H) {
1928-
self.__sig.hash(state);
1929-
self.__opaque.hash(state);
1930-
}
1931-
}
1932-
1933-
impl PartialEq for pthread_cond_t {
1934-
fn eq(&self, other: &pthread_cond_t) -> bool {
1935-
self.__sig == other.__sig
1936-
&& self
1937-
.__opaque
1938-
.iter()
1939-
.zip(other.__opaque.iter())
1940-
.all(|(a, b)| a == b)
1941-
}
1942-
}
1943-
1944-
impl Eq for pthread_cond_t {}
1945-
1946-
impl hash::Hash for pthread_cond_t {
1947-
fn hash<H: hash::Hasher>(&self, state: &mut H) {
1948-
self.__sig.hash(state);
1949-
self.__opaque.hash(state);
1950-
}
1951-
}
1952-
1953-
impl PartialEq for sockaddr_storage {
1954-
fn eq(&self, other: &sockaddr_storage) -> bool {
1955-
self.ss_len == other.ss_len
1956-
&& self.ss_family == other.ss_family
1957-
&& self
1958-
.__ss_pad1
1959-
.iter()
1960-
.zip(other.__ss_pad1.iter())
1961-
.all(|(a, b)| a == b)
1962-
&& self.__ss_align == other.__ss_align
1963-
&& self
1964-
.__ss_pad2
1965-
.iter()
1966-
.zip(other.__ss_pad2.iter())
1967-
.all(|(a, b)| a == b)
1968-
}
1969-
}
1970-
1971-
impl Eq for sockaddr_storage {}
1972-
1973-
impl hash::Hash for sockaddr_storage {
1974-
fn hash<H: hash::Hasher>(&self, state: &mut H) {
1975-
self.ss_len.hash(state);
1976-
self.ss_family.hash(state);
1977-
self.__ss_pad1.hash(state);
1978-
self.__ss_align.hash(state);
1979-
self.__ss_pad2.hash(state);
1980-
}
1981-
}
1982-
1983-
impl PartialEq for utmpx {
1984-
fn eq(&self, other: &utmpx) -> bool {
1985-
self.ut_user
1986-
.iter()
1987-
.zip(other.ut_user.iter())
1988-
.all(|(a, b)| a == b)
1989-
&& self.ut_id == other.ut_id
1990-
&& self.ut_line == other.ut_line
1991-
&& self.ut_pid == other.ut_pid
1992-
&& self.ut_type == other.ut_type
1993-
&& self.ut_tv == other.ut_tv
1994-
&& self
1995-
.ut_host
1996-
.iter()
1997-
.zip(other.ut_host.iter())
1998-
.all(|(a, b)| a == b)
1999-
&& self.ut_pad == other.ut_pad
2000-
}
2001-
}
2002-
2003-
impl Eq for utmpx {}
2004-
2005-
impl hash::Hash for utmpx {
2006-
fn hash<H: hash::Hasher>(&self, state: &mut H) {
2007-
self.ut_user.hash(state);
2008-
self.ut_id.hash(state);
2009-
self.ut_line.hash(state);
2010-
self.ut_pid.hash(state);
2011-
self.ut_type.hash(state);
2012-
self.ut_tv.hash(state);
2013-
self.ut_host.hash(state);
2014-
self.ut_pad.hash(state);
2015-
}
2016-
}
2017-
2018-
impl PartialEq for sigevent {
2019-
fn eq(&self, other: &sigevent) -> bool {
2020-
self.sigev_notify == other.sigev_notify
2021-
&& self.sigev_signo == other.sigev_signo
2022-
&& self.sigev_value == other.sigev_value
2023-
&& self.sigev_notify_attributes == other.sigev_notify_attributes
2024-
}
2025-
}
2026-
2027-
impl Eq for sigevent {}
2028-
2029-
impl hash::Hash for sigevent {
2030-
fn hash<H: hash::Hasher>(&self, state: &mut H) {
2031-
self.sigev_notify.hash(state);
2032-
self.sigev_signo.hash(state);
2033-
self.sigev_value.hash(state);
2034-
self.sigev_notify_attributes.hash(state);
2035-
}
2036-
}
2037-
20381677
impl PartialEq for processor_cpu_load_info {
20391678
fn eq(&self, other: &processor_cpu_load_info) -> bool {
20401679
self.cpu_ticks == other.cpu_ticks

0 commit comments

Comments
 (0)