summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBryant Mairs <bryant@mai.rs>2019-03-10 08:29:23 -0700
committerBryant Mairs <bryant@mai.rs>2019-06-09 11:31:46 -0700
commitc50e987b4e169e2d7dc7089c91407e1e55c550f1 (patch)
tree4892e791f8809dfa1501e9fa4ff999a106a8dd04 /src
parent2075ac70bdd4848b08213a237feb32f5506096e0 (diff)
downloadnix-c50e987b4e169e2d7dc7089c91407e1e55c550f1.zip
Add extra traits for all types
Derive Clone, Copy, Eq, Hash, and PartialEq for all types. Not all traits are supported by all types, which is why many are missing some.
Diffstat (limited to 'src')
-rw-r--r--src/dir.rs27
-rw-r--r--src/fcntl.rs5
-rw-r--r--src/ifaddrs.rs2
-rw-r--r--src/lib.rs2
-rw-r--r--src/mqueue.rs13
-rw-r--r--src/poll.rs20
-rw-r--r--src/pty.rs5
-rw-r--r--src/sched.rs3
-rw-r--r--src/sys/aio.rs10
-rw-r--r--src/sys/epoll.rs3
-rw-r--r--src/sys/event.rs3
-rw-r--r--src/sys/quota.rs3
-rw-r--r--src/sys/select.rs3
-rw-r--r--src/sys/sendfile.rs2
-rw-r--r--src/sys/signal.rs38
-rw-r--r--src/sys/socket/addr.rs364
-rw-r--r--src/sys/socket/mod.rs75
-rw-r--r--src/sys/socket/sockopt.rs6
-rw-r--r--src/sys/statvfs.rs3
-rw-r--r--src/sys/sysinfo.rs3
-rw-r--r--src/sys/termios.rs3
-rw-r--r--src/sys/time.rs42
-rw-r--r--src/sys/uio.rs5
-rw-r--r--src/sys/utsname.rs3
-rw-r--r--src/sys/wait.rs2
-rw-r--r--src/ucontext.rs3
26 files changed, 77 insertions, 571 deletions
diff --git a/src/dir.rs b/src/dir.rs
index 814e9e0c..d4fc43a4 100644
--- a/src/dir.rs
+++ b/src/dir.rs
@@ -3,7 +3,7 @@ use errno::Errno;
use fcntl::{self, OFlag};
use libc;
use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd};
-use std::{ffi, fmt, ptr};
+use std::{ffi, ptr};
use sys;
#[cfg(target_os = "linux")]
@@ -25,6 +25,7 @@ use libc::{dirent, readdir_r};
/// * returns entries for `.` (current directory) and `..` (parent directory).
/// * returns entries' names as a `CStr` (no allocation or conversion beyond whatever libc
/// does).
+#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct Dir(
// This could be ptr::NonNull once nix requires Rust 1.25.
*mut libc::DIR
@@ -82,21 +83,13 @@ impl AsRawFd for Dir {
}
}
-impl fmt::Debug for Dir {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.debug_struct("Dir")
- .field("fd", &self.as_raw_fd())
- .finish()
- }
-}
-
impl Drop for Dir {
fn drop(&mut self) {
unsafe { libc::closedir(self.0) };
}
}
-#[derive(Debug)]
+#[derive(Debug, Eq, Hash, PartialEq)]
pub struct Iter<'d>(&'d mut Dir);
impl<'d> Iterator for Iter<'d> {
@@ -132,10 +125,10 @@ impl<'d> Drop for Iter<'d> {
/// A directory entry, similar to `std::fs::DirEntry`.
///
/// Note that unlike the std version, this may represent the `.` or `..` entries.
-#[derive(Copy, Clone)]
+#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub struct Entry(dirent);
-#[derive(Copy, Clone, Debug, Eq, PartialEq)]
+#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub enum Type {
Fifo,
CharacterDevice,
@@ -198,13 +191,3 @@ impl Entry {
}
}
}
-
-impl fmt::Debug for Entry {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.debug_struct("Entry")
- .field("ino", &self.ino())
- .field("file_name", &self.file_name())
- .field("file_type", &self.file_type())
- .finish()
- }
-}
diff --git a/src/fcntl.rs b/src/fcntl.rs
index 40f4cf94..6da62d87 100644
--- a/src/fcntl.rs
+++ b/src/fcntl.rs
@@ -214,7 +214,7 @@ libc_bitflags!(
}
);
-#[allow(missing_debug_implementations)]
+#[derive(Debug, Eq, Hash, PartialEq)]
pub enum FcntlArg<'a> {
F_DUPFD(RawFd),
F_DUPFD_CLOEXEC(RawFd),
@@ -277,8 +277,7 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result<c_int> {
Errno::result(res)
}
-#[derive(Clone, Copy)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum FlockArg {
LockShared,
LockExclusive,
diff --git a/src/ifaddrs.rs b/src/ifaddrs.rs
index c9790773..12b59bcc 100644
--- a/src/ifaddrs.rs
+++ b/src/ifaddrs.rs
@@ -15,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, Debug)]
+#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct InterfaceAddress {
/// Name of the network interface
pub interface_name: String,
diff --git a/src/lib.rs b/src/lib.rs
index 7ef91f4e..b4648933 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -98,7 +98,7 @@ pub type Result<T> = result::Result<T, Error>;
/// error has a corresponding errno (usually the one from the
/// underlying OS) to which it can be mapped in addition to
/// implementing other common traits.
-#[derive(Clone, Copy, Debug, PartialEq)]
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Error {
Sys(Errno),
InvalidPath,
diff --git a/src/mqueue.rs b/src/mqueue.rs
index 87be6532..b958b71c 100644
--- a/src/mqueue.rs
+++ b/src/mqueue.rs
@@ -29,22 +29,11 @@ libc_bitflags!{
}
#[repr(C)]
-#[derive(Clone, Copy)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct MqAttr {
mq_attr: libc::mq_attr,
}
-impl PartialEq<MqAttr> for MqAttr {
- fn eq(&self, other: &MqAttr) -> bool {
- let self_attr = self.mq_attr;
- let other_attr = other.mq_attr;
- self_attr.mq_flags == other_attr.mq_flags && self_attr.mq_maxmsg == other_attr.mq_maxmsg &&
- self_attr.mq_msgsize == other_attr.mq_msgsize &&
- self_attr.mq_curmsgs == other_attr.mq_curmsgs
- }
-}
-
impl MqAttr {
pub fn new(mq_flags: c_long,
mq_maxmsg: c_long,
diff --git a/src/poll.rs b/src/poll.rs
index 160b5bc6..c603611e 100644
--- a/src/poll.rs
+++ b/src/poll.rs
@@ -4,7 +4,6 @@ use sys::time::TimeSpec;
#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))]
use sys::signal::SigSet;
use std::os::unix::io::RawFd;
-use std::fmt;
use libc;
use Result;
@@ -19,7 +18,7 @@ use errno::Errno;
/// After a call to `poll` or `ppoll`, the events that occured can be
/// retrieved by calling [`revents()`](#method.revents) on the `PollFd`.
#[repr(C)]
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct PollFd {
pollfd: libc::pollfd,
}
@@ -43,23 +42,6 @@ impl PollFd {
}
}
-impl fmt::Debug for PollFd {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- let pfd = self.pollfd;
- let mut ds = f.debug_struct("PollFd");
- ds.field("fd", &pfd.fd);
- match PollFlags::from_bits(pfd.events) {
- None => ds.field("events", &pfd.events),
- Some(ef) => ds.field("events", &ef),
- };
- match PollFlags::from_bits(pfd.revents) {
- None => ds.field("revents", &pfd.revents),
- Some(ef) => ds.field("revents", &ef),
- };
- ds.finish()
- }
-}
-
libc_bitflags! {
/// These flags define the different events that can be monitored by `poll` and `ppoll`
pub struct PollFlags: libc::c_short {
diff --git a/src/pty.rs b/src/pty.rs
index 41bd51b6..db012d81 100644
--- a/src/pty.rs
+++ b/src/pty.rs
@@ -18,8 +18,7 @@ use errno::Errno;
///
/// This is returned by `openpty`. Note that this type does *not* implement `Drop`, so the user
/// must manually close the file descriptors.
-#[derive(Clone, Copy)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct OpenptyResult {
/// The master port in a virtual pty pair
pub master: RawFd,
@@ -45,7 +44,7 @@ pub struct ForkptyResult {
/// While this datatype is a thin wrapper around `RawFd`, it enforces that the available PTY
/// functions are given the correct file descriptor. Additionally this type implements `Drop`,
/// so that when it's consumed or goes out of scope, it's automatically cleaned-up.
-#[derive(Debug)]
+#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct PtyMaster(RawFd);
impl AsRawFd for PtyMaster {
diff --git a/src/sched.rs b/src/sched.rs
index d381cbb5..c4e6ca7a 100644
--- a/src/sched.rs
+++ b/src/sched.rs
@@ -39,8 +39,7 @@ libc_bitflags!{
pub type CloneCb<'a> = Box<FnMut() -> isize + 'a>;
#[repr(C)]
-#[derive(Clone, Copy)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct CpuSet {
cpu_set: libc::cpu_set_t,
}
diff --git a/src/sys/aio.rs b/src/sys/aio.rs
index c54c2e31..40fa4e15 100644
--- a/src/sys/aio.rs
+++ b/src/sys/aio.rs
@@ -80,7 +80,7 @@ libc_enum! {
/// Return values for [`AioCb::cancel`](struct.AioCb.html#method.cancel) and
/// [`aio_cancel_all`](fn.aio_cancel_all.html)
#[repr(i32)]
-#[derive(Clone, Copy, Debug, PartialEq)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum AioCancelStat {
/// All outstanding requests were canceled
AioCanceled = libc::AIO_CANCELED,
@@ -1021,13 +1021,7 @@ pub fn aio_suspend(list: &[&AioCb], timeout: Option<TimeSpec>) -> Result<()> {
impl<'a> Debug for AioCb<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct("AioCb")
- .field("aio_fildes", &self.aiocb.aio_fildes)
- .field("aio_offset", &self.aiocb.aio_offset)
- .field("aio_buf", &self.aiocb.aio_buf)
- .field("aio_nbytes", &self.aiocb.aio_nbytes)
- .field("aio_lio_opcode", &self.aiocb.aio_lio_opcode)
- .field("aio_reqprio", &self.aiocb.aio_reqprio)
- .field("aio_sigevent", &SigEvent::from(&self.aiocb.aio_sigevent))
+ .field("aiocb", &self.aiocb)
.field("mutable", &self.mutable)
.field("in_progress", &self.in_progress)
.finish()
diff --git a/src/sys/epoll.rs b/src/sys/epoll.rs
index 3ed1dd72..fef6f4e3 100644
--- a/src/sys/epoll.rs
+++ b/src/sys/epoll.rs
@@ -42,8 +42,7 @@ libc_bitflags!{
}
}
-#[allow(missing_debug_implementations)]
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[repr(C)]
pub struct EpollEvent {
event: libc::epoll_event,
diff --git a/src/sys/event.rs b/src/sys/event.rs
index f1eaa0d1..8cd7372f 100644
--- a/src/sys/event.rs
+++ b/src/sys/event.rs
@@ -12,9 +12,8 @@ use std::ptr;
use std::mem;
// Redefine kevent in terms of programmer-friendly enums and bitfields.
-#[derive(Clone, Copy)]
#[repr(C)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct KEvent {
kevent: libc::kevent,
}
diff --git a/src/sys/quota.rs b/src/sys/quota.rs
index 14c04629..8946fca2 100644
--- a/src/sys/quota.rs
+++ b/src/sys/quota.rs
@@ -96,8 +96,7 @@ libc_bitflags!(
/// Wrapper type for `if_dqblk`
// FIXME: Change to repr(transparent)
#[repr(C)]
-#[derive(Clone, Copy)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Dqblk(libc::dqblk);
impl Default for Dqblk {
diff --git a/src/sys/select.rs b/src/sys/select.rs
index 95b6b148..1b518e29 100644
--- a/src/sys/select.rs
+++ b/src/sys/select.rs
@@ -11,8 +11,7 @@ pub use libc::FD_SETSIZE;
// FIXME: Change to repr(transparent) once it's stable
#[repr(C)]
-#[derive(Clone, Copy)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct FdSet(libc::fd_set);
impl FdSet {
diff --git a/src/sys/sendfile.rs b/src/sys/sendfile.rs
index 1190518d..a47d8962 100644
--- a/src/sys/sendfile.rs
+++ b/src/sys/sendfile.rs
@@ -38,7 +38,7 @@ cfg_if! {
target_os = "macos"))] {
use sys::uio::IoVec;
- #[allow(missing_debug_implementations)]
+ #[derive(Clone, Debug, Eq, Hash, PartialEq)]
struct SendfileHeaderTrailer<'a>(
libc::sf_hdtr,
Option<Vec<IoVec<&'a [u8]>>>,
diff --git a/src/sys/signal.rs b/src/sys/signal.rs
index a49b273f..1013a77f 100644
--- a/src/sys/signal.rs
+++ b/src/sys/signal.rs
@@ -265,8 +265,7 @@ const SIGNALS: [Signal; 31] = [
pub const NSIG: libc::c_int = 32;
-#[derive(Clone, Copy)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct SignalIterator {
next: usize,
}
@@ -328,8 +327,7 @@ libc_enum! {
}
}
-#[derive(Clone, Copy)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct SigSet {
sigset: libc::sigset_t
}
@@ -427,7 +425,7 @@ impl AsRef<libc::sigset_t> for SigSet {
/// A signal handler.
#[allow(unknown_lints)]
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum SigHandler {
/// Default signal handling.
SigDfl,
@@ -441,8 +439,7 @@ pub enum SigHandler {
}
/// Action to take on receipt of a signal. Corresponds to `sigaction`.
-#[derive(Clone, Copy)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct SigAction {
sigaction: libc::sigaction
}
@@ -683,7 +680,7 @@ pub type type_of_thread_id = libc::pid_t;
// sigval is actually a union of a int and a void*. But it's never really used
// as a pointer, because neither libc nor the kernel ever dereference it. nix
// therefore presents it as an intptr_t, which is how kevent uses it.
-#[derive(Clone, Copy, Debug, PartialEq)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum SigevNotify {
/// No notification will be delivered
SigevNone,
@@ -710,7 +707,6 @@ mod sigevent {
use libc;
use std::mem;
use std::ptr;
- use std::fmt::{self, Debug};
use super::SigevNotify;
#[cfg(any(target_os = "freebsd", target_os = "linux"))]
use super::type_of_thread_id;
@@ -718,7 +714,7 @@ mod sigevent {
/// Used to request asynchronous notification of the completion of certain
/// events, such as POSIX AIO and timers.
#[repr(C)]
- #[derive(Clone, Copy)]
+ #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct SigEvent {
sigevent: libc::sigevent
}
@@ -788,28 +784,6 @@ mod sigevent {
}
}
- impl Debug for SigEvent {
- #[cfg(any(target_os = "freebsd", target_os = "linux"))]
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- fmt.debug_struct("SigEvent")
- .field("sigev_notify", &self.sigevent.sigev_notify)
- .field("sigev_signo", &self.sigevent.sigev_signo)
- .field("sigev_value", &self.sigevent.sigev_value.sival_ptr)
- .field("sigev_notify_thread_id",
- &self.sigevent.sigev_notify_thread_id)
- .finish()
- }
-
- #[cfg(not(any(target_os = "freebsd", target_os = "linux")))]
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- fmt.debug_struct("SigEvent")
- .field("sigev_notify", &self.sigevent.sigev_notify)
- .field("sigev_signo", &self.sigevent.sigev_signo)
- .field("sigev_value", &self.sigevent.sigev_value.sival_ptr)
- .finish()
- }
- }
-
impl<'a> From<&'a libc::sigevent> for SigEvent {
fn from(sigevent: &libc::sigevent) -> Self {
SigEvent{ sigevent: *sigevent }
diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs
index fc24bd79..c6988227 100644
--- a/src/sys/socket/addr.rs
+++ b/src/sys/socket/addr.rs
@@ -2,8 +2,9 @@ use super::sa_family_t;
use {Error, Result, NixPath};
use errno::Errno;
use libc;
-use std::{fmt, hash, mem, net, ptr, slice};
+use std::{fmt, mem, net, ptr, slice};
use std::ffi::OsStr;
+use std::hash::{Hash, Hasher};
use std::path::Path;
use std::os::unix::ffi::OsStrExt;
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -245,7 +246,7 @@ impl AddressFamily {
}
}
-#[derive(Copy)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum InetAddr {
V4(libc::sockaddr_in),
V6(libc::sockaddr_in6),
@@ -331,52 +332,6 @@ impl InetAddr {
}
}
-impl PartialEq for InetAddr {
- fn eq(&self, other: &InetAddr) -> bool {
- match (*self, *other) {
- (InetAddr::V4(ref a), InetAddr::V4(ref b)) => {
- a.sin_port == b.sin_port &&
- a.sin_addr.s_addr == b.sin_addr.s_addr
- }
- (InetAddr::V6(ref a), InetAddr::V6(ref b)) => {
- a.sin6_port == b.sin6_port &&
- a.sin6_addr.s6_addr == b.sin6_addr.s6_addr &&
- a.sin6_flowinfo == b.sin6_flowinfo &&
- a.sin6_scope_id == b.sin6_scope_id
- }
- _ => false,
- }
- }
-}
-
-impl Eq for InetAddr {
-}
-
-impl hash::Hash for InetAddr {
- fn hash<H: hash::Hasher>(&self, s: &mut H) {
- match *self {
- InetAddr::V4(ref a) => {
- ( a.sin_family,
- a.sin_port,
- a.sin_addr.s_addr ).hash(s)
- }
- InetAddr::V6(ref a) => {
- ( a.sin6_family,
- a.sin6_port,
- &a.sin6_addr.s6_addr,
- a.sin6_flowinfo,
- a.sin6_scope_id ).hash(s)
- }
- }
- }
-}
-
-impl Clone for InetAddr {
- fn clone(&self) -> InetAddr {
- *self
- }
-}
-
impl fmt::Display for InetAddr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
@@ -386,18 +341,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 =====
*
*/
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum IpAddr {
V4(Ipv4Addr),
V6(Ipv6Addr),
@@ -442,19 +391,13 @@ 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 =====
*
*/
-#[derive(Copy)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Ipv4Addr(pub libc::in_addr);
impl Ipv4Addr {
@@ -487,28 +430,6 @@ impl Ipv4Addr {
}
}
-impl PartialEq for Ipv4Addr {
- fn eq(&self, other: &Ipv4Addr) -> bool {
- self.0.s_addr == other.0.s_addr
- }
-}
-
-impl Eq for Ipv4Addr {
-}
-
-impl hash::Hash for Ipv4Addr {
- fn hash<H: hash::Hasher>(&self, s: &mut H) {
- let saddr = self.0.s_addr;
- saddr.hash(s)
- }
-}
-
-impl Clone for Ipv4Addr {
- fn clone(&self) -> Ipv4Addr {
- *self
- }
-}
-
impl fmt::Display for Ipv4Addr {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let octets = self.octets();
@@ -516,19 +437,13 @@ 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 =====
*
*/
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Ipv6Addr(pub libc::in6_addr);
// Note that IPv6 addresses are stored in big endian order on all architectures.
@@ -576,18 +491,6 @@ 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 =====
- *
- */
-
/// A wrapper around `sockaddr_un`.
///
/// This also tracks the length of `sun_path` address (excluding
@@ -596,7 +499,7 @@ impl fmt::Debug for Ipv6Addr {
/// does not require that `sun_len` include the terminating null even for normal
/// sockets. Note that the actual sockaddr length is greater by
/// `offset_of!(libc::sockaddr_un, sun_path)`
-#[derive(Copy)]
+#[derive(Clone, Copy, Debug)]
pub struct UnixAddr(pub libc::sockaddr_un, pub usize);
impl UnixAddr {
@@ -688,27 +591,6 @@ impl UnixAddr {
}
}
-impl PartialEq for UnixAddr {
- fn eq(&self, other: &UnixAddr) -> bool {
- self.sun_path() == other.sun_path()
- }
-}
-
-impl Eq for UnixAddr {
-}
-
-impl hash::Hash for UnixAddr {
- fn hash<H: hash::Hasher>(&self, s: &mut H) {
- ( self.0.sun_family, self.sun_path() ).hash(s)
- }
-}
-
-impl Clone for UnixAddr {
- fn clone(&self) -> UnixAddr {
- *self
- }
-}
-
impl fmt::Display for UnixAddr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.1 == 0 {
@@ -722,20 +604,22 @@ impl fmt::Display for UnixAddr {
}
}
-impl fmt::Debug for UnixAddr {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- fmt::Display::fmt(self, f)
+impl PartialEq for UnixAddr {
+ fn eq(&self, other: &UnixAddr) -> bool {
+ self.sun_path() == other.sun_path()
}
}
-/*
- *
- * ===== Sock addr =====
- *
- */
+impl Eq for UnixAddr {}
+
+impl Hash for UnixAddr {
+ fn hash<H: Hasher>(&self, s: &mut H) {
+ ( self.0.sun_family, self.sun_path() ).hash(s)
+ }
+}
/// Represents a socket address
-#[derive(Copy, Debug)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum SockAddr {
Inet(InetAddr),
Unix(UnixAddr),
@@ -883,68 +767,6 @@ impl SockAddr {
}
}
-impl PartialEq for SockAddr {
- fn eq(&self, other: &SockAddr) -> bool {
- match (*self, *other) {
- (SockAddr::Inet(ref a), SockAddr::Inet(ref b)) => {
- a == b
- }
- (SockAddr::Unix(ref a), SockAddr::Unix(ref b)) => {
- a == b
- }
- #[cfg(any(target_os = "android", target_os = "linux"))]
- (SockAddr::Netlink(ref a), SockAddr::Netlink(ref b)) => {
- a == b
- }
- #[cfg(any(target_os = "android",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "linux",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd"))]
- (SockAddr::Link(ref a), SockAddr::Link(ref b)) => {
- a == b
- }
- _ => false,
- }
- }
-}
-
-impl Eq for SockAddr {
-}
-
-impl hash::Hash for SockAddr {
- fn hash<H: hash::Hasher>(&self, s: &mut H) {
- match *self {
- SockAddr::Inet(ref a) => a.hash(s),
- SockAddr::Unix(ref a) => a.hash(s),
- #[cfg(any(target_os = "android", target_os = "linux"))]
- SockAddr::Netlink(ref a) => a.hash(s),
- #[cfg(any(target_os = "android", target_os = "linux"))]
- SockAddr::Alg(ref a) => a.hash(s),
- #[cfg(any(target_os = "ios", target_os = "macos"))]
- SockAddr::SysControl(ref a) => a.hash(s),
- #[cfg(any(target_os = "android",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "ios",
- target_os = "linux",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd"))]
- SockAddr::Link(ref ether_addr) => ether_addr.hash(s)
- }
- }
-}
-
-impl Clone for SockAddr {
- fn clone(&self) -> SockAddr {
- *self
- }
-}
-
impl fmt::Display for SockAddr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
@@ -974,30 +796,10 @@ pub mod netlink {
use ::sys::socket::addr::AddressFamily;
use libc::{sa_family_t, sockaddr_nl};
use std::{fmt, mem};
- use std::hash::{Hash, Hasher};
- #[derive(Copy, Clone)]
+ #[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub struct NetlinkAddr(pub sockaddr_nl);
- // , PartialEq, Eq, Debug, Hash
- impl PartialEq for NetlinkAddr {
- fn eq(&self, other: &Self) -> bool {
- let (inner, other) = (self.0, other.0);
- (inner.nl_family, inner.nl_pid, inner.nl_groups) ==
- (other.nl_family, other.nl_pid, other.nl_groups)
- }
- }
-
- impl Eq for NetlinkAddr {}
-
- impl Hash for NetlinkAddr {
- fn hash<H: Hasher>(&self, s: &mut H) {
- let inner = self.0;
- (inner.nl_family, inner.nl_pid, inner.nl_groups).hash(s);
- }
- }
-
-
impl NetlinkAddr {
pub fn new(pid: u32, groups: u32) -> NetlinkAddr {
let mut addr: sockaddr_nl = unsafe { mem::zeroed() };
@@ -1022,12 +824,6 @@ 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 = "android", target_os = "linux"))]
@@ -1098,11 +894,13 @@ pub mod sys_control {
use ::sys::socket::addr::AddressFamily;
use libc::{self, c_uchar};
use std::{fmt, mem};
- use std::hash::{Hash, Hasher};
use std::os::unix::io::RawFd;
use {Errno, Error, Result};
+ // FIXME: Move type into `libc`
#[repr(C)]
+ #[derive(Clone, Copy)]
+ #[allow(missing_debug_implementations)]
pub struct ctl_ioc_info {
pub ctl_id: u32,
pub ctl_name: [c_uchar; MAX_KCTL_NAME],
@@ -1114,28 +912,10 @@ pub mod sys_control {
ioctl_readwrite!(ctl_info, CTL_IOC_MAGIC, CTL_IOC_INFO, ctl_ioc_info);
- #[derive(Copy, Clone)]
#[repr(C)]
+ #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct SysControlAddr(pub libc::sockaddr_ctl);
- impl PartialEq for SysControlAddr {
- fn eq(&self, other: &Self) -> bool {
- let (inner, other) = (self.0, other.0);
- (inner.sc_id, inner.sc_unit) ==
- (other.sc_id, other.sc_unit)
- }
- }
-
- impl Eq for SysControlAddr {}
-
- impl Hash for SysControlAddr {
- fn hash<H: Hasher>(&self, s: &mut H) {
- let inner = self.0;
- (inner.sc_id, inner.sc_unit).hash(s);
- }
- }
-
-
impl SysControlAddr {
pub fn new(id: u32, unit: u32) -> SysControlAddr {
let addr = libc::sockaddr_ctl {
@@ -1178,27 +958,15 @@ pub mod sys_control {
fmt::Debug::fmt(self, f)
}
}
-
- impl fmt::Debug for SysControlAddr {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.debug_struct("SysControlAddr")
- .field("sc_len", &self.0.sc_len)
- .field("sc_family", &self.0.sc_family)
- .field("ss_sysaddr", &self.0.ss_sysaddr)
- .field("sc_id", &self.0.sc_id)
- .field("sc_unit", &self.0.sc_unit)
- .finish()
- }
- }
}
#[cfg(any(target_os = "android", target_os = "linux"))]
mod datalink {
- use super::{libc, hash, fmt, AddressFamily};
+ use super::{libc, fmt, AddressFamily};
/// Hardware Address
- #[derive(Clone, Copy)]
+ #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct LinkAddr(pub libc::sockaddr_ll);
impl LinkAddr {
@@ -1246,26 +1014,6 @@ mod datalink {
}
}
- impl Eq for LinkAddr {}
-
- impl PartialEq for LinkAddr {
- fn eq(&self, other: &Self) -> bool {
- let (a, b) = (self.0, other.0);
- (a.sll_family, a.sll_protocol, a.sll_ifindex, a.sll_hatype,
- a.sll_pkttype, a.sll_halen, a.sll_addr) ==
- (b.sll_family, b.sll_protocol, b.sll_ifindex, b.sll_hatype,
- b.sll_pkttype, b.sll_halen, b.sll_addr)
- }
- }
-
- impl hash::Hash for LinkAddr {
- fn hash<H: hash::Hasher>(&self, s: &mut H) {
- let a = self.0;
- (a.sll_family, a.sll_protocol, a.sll_ifindex, a.sll_hatype,
- a.sll_pkttype, a.sll_halen, a.sll_addr).hash(s);
- }
- }
-
impl fmt::Display for LinkAddr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let addr = self.addr();
@@ -1278,12 +1026,6 @@ mod datalink {
addr[5])
}
}
-
- impl fmt::Debug for LinkAddr {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- fmt::Display::fmt(self, f)
- }
- }
}
#[cfg(any(target_os = "dragonfly",
@@ -1293,10 +1035,10 @@ mod datalink {
target_os = "netbsd",
target_os = "openbsd"))]
mod datalink {
- use super::{libc, hash, fmt, AddressFamily};
+ use super::{libc, fmt, AddressFamily};
/// Hardware Address
- #[derive(Clone, Copy)]
+ #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct LinkAddr(pub libc::sockaddr_dl);
impl LinkAddr {
@@ -1368,52 +1110,6 @@ mod datalink {
}
}
- impl Eq for LinkAddr {}
-
- impl PartialEq for LinkAddr {
- #[cfg(any(target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd"))]
- fn eq(&self, other: &Self) -> bool {
- let (a, b) = (self.0, other.0);
- (a.sdl_len, a.sdl_family, a.sdl_index, a.sdl_type,
- a.sdl_nlen, a.sdl_alen, a.sdl_slen, &a.sdl_data[..]) ==
- (b.sdl_len, b.sdl_family, b.sdl_index, b.sdl_type,
- b.sdl_nlen, b.sdl_alen, b.sdl_slen, &b.sdl_data[..])
- }
-
- #[cfg(target_os = "dragonfly")]
- fn eq(&self, other: &Self) -> bool {
- let (a, b) = (self.0, other.0);
- (a.sdl_len, a.sdl_family, a.sdl_index, a.sdl_type, a.sdl_nlen,
- a.sdl_alen, a.sdl_slen, a.sdl_data, a.sdl_rcf, a.sdl_route) ==
- (b.sdl_len, b.sdl_family, b.sdl_index, b.sdl_type, b.sdl_nlen,
- b.sdl_alen, b.sdl_slen, b.sdl_data, b.sdl_rcf, b.sdl_route)
- }
- }
-
- impl hash::Hash for LinkAddr {
- #[cfg(any(target_os = "freebsd",
- target_os = "ios",
- target_os = "macos",
- target_os = "netbsd",
- target_os = "openbsd"))]
- fn hash<H: hash::Hasher>(&self, s: &mut H) {
- let a = self.0;
- (a.sdl_len, a.sdl_family, a.sdl_index, a.sdl_type,
- a.sdl_nlen, a.sdl_alen, a.sdl_slen, &a.sdl_data[..]).hash(s);
- }
-
- #[cfg(target_os = "dragonfly")]
- fn hash<H: hash::Hasher>(&self, s: &mut H) {
- let a = self.0;
- (a.sdl_len, a.sdl_family, a.sdl_index, a.sdl_type, a.sdl_nlen,
- a.sdl_alen, a.sdl_slen, a.sdl_data, a.sdl_rcf, a.sdl_route).hash(s);
- }
- }
-
impl fmt::Display for LinkAddr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let addr = self.addr();
@@ -1426,12 +1122,6 @@ mod datalink {
addr[5])
}
}
-
- impl fmt::Debug for LinkAddr {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- fmt::Display::fmt(self, f)
- }
- }
}
#[cfg(test)]
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index a8631f24..0e27216f 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -5,7 +5,7 @@ use {Error, Result};
use errno::Errno;
use libc::{self, c_void, c_int, iovec, socklen_t, size_t,
CMSG_FIRSTHDR, CMSG_NXTHDR, CMSG_DATA, CMSG_LEN};
-use std::{fmt, mem, ptr, slice};
+use std::{mem, ptr, slice};
use std::os::unix::io::RawFd;
use sys::time::TimeVal;
use sys::uio::IoVec;
@@ -189,7 +189,7 @@ cfg_if! {
///
/// This struct is used with the `SO_PEERCRED` ancillary message for UNIX sockets.
#[repr(C)]
- #[derive(Clone, Copy)]
+ #[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct UnixCredentials(libc::ucred);
impl UnixCredentials {
@@ -209,13 +209,6 @@ cfg_if! {
}
}
- impl PartialEq for UnixCredentials {
- fn eq(&self, other: &Self) -> bool {
- self.0.pid == other.0.pid && self.0.uid == other.0.uid && self.0.gid == other.0.gid
- }
- }
- impl Eq for UnixCredentials {}
-
impl From<libc::ucred> for UnixCredentials {
fn from(cred: libc::ucred) -> Self {
UnixCredentials(cred)
@@ -227,16 +220,6 @@ cfg_if! {
self.0
}
}
-
- impl fmt::Debug for UnixCredentials {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.debug_struct("UnixCredentials")
- .field("pid", &self.0.pid)
- .field("uid", &self.0.uid)
- .field("gid", &self.0.gid)
- .finish()
- }
- }
}
}
@@ -244,7 +227,7 @@ cfg_if! {
///
/// This is a wrapper type around `ip_mreq`.
#[repr(C)]
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct IpMembershipRequest(libc::ip_mreq);
impl IpMembershipRequest {
@@ -259,32 +242,11 @@ impl IpMembershipRequest {
}
}
-impl PartialEq for IpMembershipRequest {
- fn eq(&self, other: &Self) -> bool {
- self.0.imr_multiaddr.s_addr == other.0.imr_multiaddr.s_addr
- && self.0.imr_interface.s_addr == other.0.imr_interface.s_addr
- }
-}
-impl Eq for IpMembershipRequest {}
-
-impl fmt::Debug for IpMembershipRequest {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- let mref = &self.0.imr_multiaddr;
- let maddr = mref.s_addr;
- let iref = &self.0.imr_interface;
- let ifaddr = iref.s_addr;
- f.debug_struct("IpMembershipRequest")
- .field("imr_multiaddr", &maddr)
- .field("imr_interface", &ifaddr)
- .finish()
- }
-}
-
/// Request for ipv6 multicast socket operations
///
/// This is a wrapper type around `ipv6_mreq`.
#[repr(C)]
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct Ipv6MembershipRequest(libc::ipv6_mreq);
impl Ipv6MembershipRequest {
@@ -297,23 +259,6 @@ impl Ipv6MembershipRequest {
}
}
-impl PartialEq for Ipv6MembershipRequest {
- fn eq(&self, other: &Self) -> bool {
- self.0.ipv6mr_multiaddr.s6_addr == other.0.ipv6mr_multiaddr.s6_addr &&
- self.0.ipv6mr_interface == other.0.ipv6mr_interface
- }
-}
-impl Eq for Ipv6MembershipRequest {}
-
-impl fmt::Debug for Ipv6MembershipRequest {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- f.debug_struct("Ipv6MembershipRequest")
- .field("ipv6mr_multiaddr", &self.0.ipv6mr_multiaddr.s6_addr)
- .field("ipv6mr_interface", &self.0.ipv6mr_interface)
- .finish()
- }
-}
-
cfg_if! {
// Darwin and DragonFly BSD always align struct cmsghdr to 32-bit only.
if #[cfg(any(target_os = "dragonfly", target_os = "ios", target_os = "macos"))] {
@@ -386,7 +331,7 @@ macro_rules! cmsg_space {
/// let cmsg: CmsgSpace<([RawFd; 3], CmsgSpace<[RawFd; 2]>)> = CmsgSpace::new();
/// ```
#[repr(C)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct CmsgSpace<T> {
_hdr: cmsghdr,
_pad: [align_of_cmsg_data; 0],
@@ -419,7 +364,7 @@ impl CmsgBuffer for Vec<u8> {
}
}
-#[allow(missing_debug_implementations)] // msghdr isn't Debug
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct RecvMsg<'a> {
pub bytes: usize,
cmsghdr: Option<&'a cmsghdr>,
@@ -439,7 +384,7 @@ impl<'a> RecvMsg<'a> {
}
}
-#[allow(missing_debug_implementations)] // msghdr isn't Debug
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct CmsgIterator<'a> {
/// Control message buffer to decode from. Must adhere to cmsg alignment.
cmsghdr: Option<&'a cmsghdr>,
@@ -478,7 +423,7 @@ impl<'a> Iterator for CmsgIterator<'a> {
// alignment issues.
//
// See https://github.com/nix-rust/nix/issues/999
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ControlMessageOwned {
/// Received version of
/// [`ControlMessage::ScmRights`][#enum.ControlMessage.html#variant.ScmRights]
@@ -679,7 +624,7 @@ impl ControlMessageOwned {
/// exhaustively pattern-match it.
///
/// [Further reading](http://man7.org/linux/man-pages/man3/cmsg.3.html)
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ControlMessage<'a> {
/// A message of type `SCM_RIGHTS`, containing an array of file
/// descriptors passed between processes.
@@ -742,7 +687,7 @@ pub enum ControlMessage<'a> {
// An opaque structure used to prevent cmsghdr from being a public type
#[doc(hidden)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Debug, Eq, PartialEq)]
pub struct UnknownCmsg(cmsghdr, Vec<u8>);
impl<'a> ControlMessage<'a> {
diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs
index 5f19e5f3..a9960100 100644
--- a/src/sys/socket/sockopt.rs
+++ b/src/sys/socket/sockopt.rs
@@ -173,7 +173,7 @@ macro_rules! sockopt_impl {
};
(GetOnly, $name:ident, $level:path, $flag:path, $ty:ty, $getter:ty) => {
- #[derive(Copy, Clone, Debug)]
+ #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct $name;
getsockopt_impl!($name, $level, $flag, $ty, $getter);
@@ -184,14 +184,14 @@ macro_rules! sockopt_impl {
};
(SetOnly, $name:ident, $level:path, $flag:path, $ty:ty, $setter:ty) => {
- #[derive(Copy, Clone, Debug)]
+ #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct $name;
setsockopt_impl!($name, $level, $flag, $ty, $setter);
};
(Both, $name:ident, $level:path, $flag:path, $ty:ty, $getter:ty, $setter:ty) => {
- #[derive(Copy, Clone, Debug)]
+ #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct $name;
setsockopt_impl!($name, $level, $flag, $ty, $setter);
diff --git a/src/sys/statvfs.rs b/src/sys/statvfs.rs
index de69ae51..e5980369 100644
--- a/src/sys/statvfs.rs
+++ b/src/sys/statvfs.rs
@@ -57,8 +57,7 @@ libc_bitflags!(
/// For more information see the [`statvfs(3)` man pages](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_statvfs.h.html).
// FIXME: Replace with repr(transparent)
#[repr(C)]
-#[derive(Clone, Copy)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct Statvfs(libc::statvfs);
impl Statvfs {
diff --git a/src/sys/sysinfo.rs b/src/sys/sysinfo.rs
index 98ef7bd5..4c8e3898 100644
--- a/src/sys/sysinfo.rs
+++ b/src/sys/sysinfo.rs
@@ -6,8 +6,7 @@ use Result;
use errno::Errno;
/// System info structure returned by `sysinfo`.
-#[derive(Copy, Clone)]
-#[allow(missing_debug_implementations)] // libc::sysinfo doesn't impl Debug
+#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub struct SysInfo(libc::sysinfo);
impl SysInfo {
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
index d8815baa..c7cdf10b 100644
--- a/src/sys/termios.rs
+++ b/src/sys/termios.rs
@@ -176,8 +176,7 @@ use ::unistd::Pid;
/// This is a wrapper around the `libc::termios` struct that provides a safe interface for the
/// standard fields. The only safe way to obtain an instance of this struct is to extract it from
/// an open port using `tcgetattr()`.
-#[derive(Clone)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Termios {
inner: RefCell<libc::termios>,
/// Input mode flags (see `termios.c_iflag` documentation)
diff --git a/src/sys/time.rs b/src/sys/time.rs
index 4bd3b780..3ad57543 100644
--- a/src/sys/time.rs
+++ b/src/sys/time.rs
@@ -45,7 +45,7 @@ pub trait TimeValLike: Sized {
}
#[repr(C)]
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct TimeSpec(timespec);
const NANOS_PER_SEC: i64 = 1_000_000_000;
@@ -67,25 +67,6 @@ impl AsRef<timespec> for TimeSpec {
}
}
-impl fmt::Debug for TimeSpec {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- fmt.debug_struct("TimeSpec")
- .field("tv_sec", &self.tv_sec())
- .field("tv_nsec", &self.tv_nsec())
- .finish()
- }
-}
-
-impl PartialEq for TimeSpec {
- // The implementation of cmp is simplified by assuming that the struct is
- // normalized. That is, tv_nsec must always be within [0, 1_000_000_000)
- fn eq(&self, other: &TimeSpec) -> bool {
- self.tv_sec() == other.tv_sec() && self.tv_nsec() == other.tv_nsec()
- }
-}
-
-impl Eq for TimeSpec {}
-
impl Ord for TimeSpec {
// The implementation of cmp is simplified by assuming that the struct is
// normalized. That is, tv_nsec must always be within [0, 1_000_000_000)
@@ -259,7 +240,7 @@ impl fmt::Display for TimeSpec {
#[repr(C)]
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct TimeVal(timeval);
const MICROS_PER_SEC: i64 = 1_000_000;
@@ -278,25 +259,6 @@ impl AsRef<timeval> for TimeVal {
}
}
-impl fmt::Debug for TimeVal {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- fmt.debug_struct("TimeVal")
- .field("tv_sec", &self.tv_sec())
- .field("tv_usec", &self.tv_usec())
- .finish()
- }
-}
-
-impl PartialEq for TimeVal {
- // The implementation of cmp is simplified by assuming that the struct is
- // normalized. That is, tv_usec must always be within [0, 1_000_000)
- fn eq(&self, other: &TimeVal) -> bool {
- self.tv_sec() == other.tv_sec() && self.tv_usec() == other.tv_usec()
- }
-}
-
-impl Eq for TimeVal {}
-
impl Ord for TimeVal {
// The implementation of cmp is simplified by assuming that the struct is
// normalized. That is, tv_usec must always be within [0, 1_000_000)
diff --git a/src/sys/uio.rs b/src/sys/uio.rs
index 45860be5..d089084e 100644
--- a/src/sys/uio.rs
+++ b/src/sys/uio.rs
@@ -88,8 +88,7 @@ pub fn pread(fd: RawFd, buf: &mut [u8], offset: off_t) -> Result<usize>{
/// and [`process_vm_writev`](fn.process_vm_writev.html).
#[cfg(target_os = "linux")]
#[repr(C)]
-#[derive(Clone, Copy)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct RemoteIoVec {
/// The starting address of this slice (`iov_base`).
pub base: usize,
@@ -160,7 +159,7 @@ pub fn process_vm_readv(pid: ::unistd::Pid, local_iov: &[IoVec<&mut [u8]>], remo
}
#[repr(C)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct IoVec<T>(libc::iovec, PhantomData<T>);
impl<T> IoVec<T> {
diff --git a/src/sys/utsname.rs b/src/sys/utsname.rs
index e33d0739..ab09c7d2 100644
--- a/src/sys/utsname.rs
+++ b/src/sys/utsname.rs
@@ -4,8 +4,7 @@ use std::ffi::CStr;
use std::str::from_utf8_unchecked;
#[repr(C)]
-#[derive(Clone, Copy)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct UtsName(libc::utsname);
impl UtsName {
diff --git a/src/sys/wait.rs b/src/sys/wait.rs
index 3f99757d..c54f7ec5 100644
--- a/src/sys/wait.rs
+++ b/src/sys/wait.rs
@@ -55,7 +55,7 @@ libc_bitflags!(
/// Note that there are two Linux-specific enum variants, `PtraceEvent`
/// and `PtraceSyscall`. Portable code should avoid exhaustively
/// matching on `WaitStatus`.
-#[derive(Eq, PartialEq, Clone, Copy, Debug)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum WaitStatus {
/// The process exited normally (as with `exit()` or returning from
/// `main`) with the given exit code. This case matches the C macro
diff --git a/src/ucontext.rs b/src/ucontext.rs
index c94464d5..5e10e7d1 100644
--- a/src/ucontext.rs
+++ b/src/ucontext.rs
@@ -6,8 +6,7 @@ use errno::Errno;
use std::mem;
use sys::signal::SigSet;
-#[derive(Clone, Copy)]
-#[allow(missing_debug_implementations)]
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct UContext {
context: libc::ucontext_t,
}