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 {
212212 /// ```
213213 #[ stable( feature = "time2" , since = "1.8.0" ) ]
214214 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" )
216216 }
217217
218218 /// Returns the amount of time elapsed from another instant to this one,
@@ -233,11 +233,7 @@ impl Instant {
233233 /// ```
234234 #[ unstable( feature = "checked_duration_since" , issue = "58402" ) ]
235235 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 )
241237 }
242238
243239 /// Returns the amount of time elapsed from another instant to this one,
You can’t perform that action at this time.
0 commit comments