diff options
| author | Vitaly _Vi Shukela <vi0oss@gmail.com> | 2017-12-19 00:35:43 +0300 |
|---|---|---|
| committer | Vitaly _Vi Shukela <vi0oss@gmail.com> | 2017-12-19 00:35:43 +0300 |
| commit | 1d5ead453dd96c1040a12cbb3b0180027af165c9 (patch) | |
| tree | 5df65995c6ae6eb6b136c717b5cc59e19a842d96 /src/libstd/sys/windows | |
| parent | a3a7203e2c9ed30a501da86f3fa1f9efe707ac94 (diff) | |
| download | rust-1d5ead453dd96c1040a12cbb3b0180027af165c9.tar.gz rust-1d5ead453dd96c1040a12cbb3b0180027af165c9.zip | |
Add Hash impl for SystemTime and Instant
Closes #46670.
Diffstat (limited to 'src/libstd/sys/windows')
| -rw-r--r-- | src/libstd/sys/windows/time.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libstd/sys/windows/time.rs b/src/libstd/sys/windows/time.rs index 1be29b5139a..07e64d386a1 100644 --- a/src/libstd/sys/windows/time.rs +++ b/src/libstd/sys/windows/time.rs @@ -17,11 +17,12 @@ use sys::cvt; use sys_common::mul_div_u64; use time::Duration; use convert::TryInto; +use core::hash::{Hash, Hasher}; const NANOS_PER_SEC: u64 = 1_000_000_000; const INTERVALS_PER_SEC: u64 = NANOS_PER_SEC / 100; -#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)] +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)] pub struct Instant { t: c::LARGE_INTEGER, } @@ -173,6 +174,12 @@ impl From<c::FILETIME> for SystemTime { } } +impl Hash for SystemTime { + fn hash<H : Hasher>(&self, state: &mut H) { + self.intervals().hash(state) + } +} + fn dur2intervals(d: &Duration) -> i64 { d.as_secs() .checked_mul(INTERVALS_PER_SEC) |
