about summary refs log tree commit diff
path: root/src/libstd/sys/unix/time.rs
diff options
context:
space:
mode:
authorVitaly _Vi Shukela <vi0oss@gmail.com>2017-12-19 00:35:43 +0300
committerVitaly _Vi Shukela <vi0oss@gmail.com>2017-12-19 00:35:43 +0300
commit1d5ead453dd96c1040a12cbb3b0180027af165c9 (patch)
tree5df65995c6ae6eb6b136c717b5cc59e19a842d96 /src/libstd/sys/unix/time.rs
parenta3a7203e2c9ed30a501da86f3fa1f9efe707ac94 (diff)
downloadrust-1d5ead453dd96c1040a12cbb3b0180027af165c9.tar.gz
rust-1d5ead453dd96c1040a12cbb3b0180027af165c9.zip
Add Hash impl for SystemTime and Instant
Closes #46670.
Diffstat (limited to 'src/libstd/sys/unix/time.rs')
-rw-r--r--src/libstd/sys/unix/time.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs
index 837cd7292e2..83127935909 100644
--- a/src/libstd/sys/unix/time.rs
+++ b/src/libstd/sys/unix/time.rs
@@ -11,6 +11,7 @@
 use cmp::Ordering;
 use libc;
 use time::Duration;
+use core::hash::{Hash, Hasher};
 
 pub use self::inner::{Instant, SystemTime, UNIX_EPOCH};
 use convert::TryInto;
@@ -111,6 +112,13 @@ impl Ord for Timespec {
     }
 }
 
+impl Hash for Timespec {
+    fn hash<H : Hasher>(&self, state: &mut H) {
+        self.t.tv_sec.hash(state);
+        self.t.tv_nsec.hash(state);
+    }
+}
+
 #[cfg(any(target_os = "macos", target_os = "ios"))]
 mod inner {
     use fmt;
@@ -123,12 +131,12 @@ mod inner {
     use super::NSEC_PER_SEC;
     use super::Timespec;
 
-    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
+    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
     pub struct Instant {
         t: u64
     }
 
-    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
+    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
     pub struct SystemTime {
         t: Timespec,
     }
@@ -255,12 +263,12 @@ mod inner {
 
     use super::Timespec;
 
-    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
+    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
     pub struct Instant {
         t: Timespec,
     }
 
-    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
+    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
     pub struct SystemTime {
         t: Timespec,
     }