summaryrefslogtreecommitdiff
path: root/src/sys/time.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/time.rs')
-rw-r--r--src/sys/time.rs42
1 files changed, 2 insertions, 40 deletions
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)