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