1111use cmp:: Ordering ;
1212use libc;
1313use time:: Duration ;
14+ use core:: hash:: { Hash , Hasher } ;
1415
1516pub use self :: inner:: { Instant , SystemTime , UNIX_EPOCH } ;
1617use convert:: TryInto ;
@@ -111,6 +112,13 @@ impl Ord for Timespec {
111112 }
112113}
113114
115+ impl Hash for Timespec {
116+ fn hash < H : Hasher > ( & self , state : & mut H ) {
117+ self . t . tv_sec . hash ( state) ;
118+ self . t . tv_nsec . hash ( state) ;
119+ }
120+ }
121+
114122#[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
115123mod inner {
116124 use fmt;
@@ -123,12 +131,12 @@ mod inner {
123131 use super :: NSEC_PER_SEC ;
124132 use super :: Timespec ;
125133
126- #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Debug ) ]
134+ #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Debug , Hash ) ]
127135 pub struct Instant {
128136 t : u64
129137 }
130138
131- #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord ) ]
139+ #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
132140 pub struct SystemTime {
133141 t : Timespec ,
134142 }
@@ -255,12 +263,12 @@ mod inner {
255263
256264 use super :: Timespec ;
257265
258- #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord ) ]
266+ #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
259267 pub struct Instant {
260268 t : Timespec ,
261269 }
262270
263- #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord ) ]
271+ #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
264272 pub struct SystemTime {
265273 t : Timespec ,
266274 }
0 commit comments