diff options
author | Bryant Mairs <bryant@mai.rs> | 2019-03-10 08:29:23 -0700 |
---|---|---|
committer | Bryant Mairs <bryant@mai.rs> | 2019-06-09 11:31:46 -0700 |
commit | c50e987b4e169e2d7dc7089c91407e1e55c550f1 (patch) | |
tree | 4892e791f8809dfa1501e9fa4ff999a106a8dd04 /src/sys/time.rs | |
parent | 2075ac70bdd4848b08213a237feb32f5506096e0 (diff) | |
download | nix-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/sys/time.rs')
-rw-r--r-- | src/sys/time.rs | 42 |
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) |