File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -212,7 +212,7 @@ impl Instant {
212
212
/// ```
213
213
#[ stable( feature = "time2" , since = "1.8.0" ) ]
214
214
pub fn duration_since ( & self , earlier : Instant ) -> Duration {
215
- self . 0 . sub_instant ( & earlier. 0 )
215
+ self . 0 . checked_sub_instant ( & earlier. 0 ) . expect ( "supplied instant is later than self" )
216
216
}
217
217
218
218
/// Returns the amount of time elapsed from another instant to this one,
@@ -233,11 +233,7 @@ impl Instant {
233
233
/// ```
234
234
#[ unstable( feature = "checked_duration_since" , issue = "58402" ) ]
235
235
pub fn checked_duration_since ( & self , earlier : Instant ) -> Option < Duration > {
236
- if self >= & earlier {
237
- Some ( self . 0 . sub_instant ( & earlier. 0 ) )
238
- } else {
239
- None
240
- }
236
+ self . 0 . checked_sub_instant ( & earlier. 0 )
241
237
}
242
238
243
239
/// Returns the amount of time elapsed from another instant to this one,
You can’t perform that action at this time.
0 commit comments