File tree Expand file tree Collapse file tree 1 file changed +2
-14
lines changed Expand file tree Collapse file tree 1 file changed +2
-14
lines changed Original file line number Diff line number Diff line change @@ -368,27 +368,15 @@ impl Add for Duration {
368368 type Output = Duration ;
369369
370370 fn add ( self , rhs : Duration ) -> Duration {
371- let mut secs = self . secs + rhs. secs ;
372- let mut nanos = self . nanos + rhs. nanos ;
373- if nanos >= NANOS_PER_SEC {
374- nanos -= NANOS_PER_SEC ;
375- secs += 1 ;
376- }
377- Duration { secs, nanos }
371+ self . checked_add ( & rhs) . expect ( "`Duration + Duration` overflowed" )
378372 }
379373}
380374
381375impl Sub for Duration {
382376 type Output = Duration ;
383377
384378 fn sub ( self , rhs : Duration ) -> Duration {
385- let mut secs = self . secs - rhs. secs ;
386- let mut nanos = self . nanos - rhs. nanos ;
387- if nanos < 0 {
388- nanos += NANOS_PER_SEC ;
389- secs -= 1 ;
390- }
391- Duration { secs, nanos }
379+ self . checked_sub ( & rhs) . expect ( "`Duration - Duration` overflowed" )
392380 }
393381}
394382
You can’t perform that action at this time.
0 commit comments