@@ -103,33 +103,9 @@ impl Sub<Duration> for MonotonicTime {
103
103
}
104
104
}
105
105
106
- #[ cfg( not( feature = "no-std" ) ) ]
107
- impl Time for std:: time:: Instant {
108
- fn now ( ) -> Self {
109
- std:: time:: Instant :: now ( )
110
- }
111
-
112
- fn duration_since ( & self , earlier : Self ) -> Duration {
113
- // On rust prior to 1.60 `Instant::duration_since` will panic if time goes backwards.
114
- // However, we support rust versions prior to 1.60 and some users appear to have "monotonic
115
- // clocks" that go backwards in practice (likely relatively ancient kernels/etc). Thus, we
116
- // manually check for time going backwards here and return a duration of zero in that case.
117
- let now = Self :: now ( ) ;
118
- if now > earlier { now - earlier } else { Duration :: from_secs ( 0 ) }
119
- }
120
-
121
- fn duration_since_epoch ( ) -> Duration {
122
- use std:: time:: SystemTime ;
123
- SystemTime :: now ( ) . duration_since ( SystemTime :: UNIX_EPOCH ) . unwrap ( )
124
- }
125
- fn elapsed ( & self ) -> Duration {
126
- std:: time:: Instant :: elapsed ( self )
127
- }
128
- }
129
-
130
106
#[ cfg( test) ]
131
107
pub mod tests {
132
- use super :: { Time , Eternity , MonotonicTime } ;
108
+ use super :: { Time , Eternity } ;
133
109
134
110
use core:: time:: Duration ;
135
111
use core:: ops:: Sub ;
@@ -201,8 +177,9 @@ pub mod tests {
201
177
}
202
178
203
179
#[ test]
180
+ #[ cfg( not( feature = "no-std" ) ) ]
204
181
fn monotonic_time_go_backward ( ) {
205
- let now = MonotonicTime :: now ( ) ;
182
+ let now = super :: MonotonicTime :: now ( ) ;
206
183
let ten_years = Duration :: from_secs ( 10 * 365 * 24 * 60 * 60 ) ;
207
184
let _past = now - ten_years;
208
185
}
0 commit comments