File tree Expand file tree Collapse file tree 2 files changed +6
-20
lines changed Expand file tree Collapse file tree 2 files changed +6
-20
lines changed Original file line number Diff line number Diff line change @@ -46,25 +46,18 @@ impl Timespec {
4646 }
4747
4848 fn checked_add_duration ( & self , other : & Duration ) -> Option < Timespec > {
49- let mut secs = match other
49+ let mut secs = other
5050 . as_secs ( )
5151 . try_into ( ) // <- target type would be `i64`
5252 . ok ( )
53- . and_then ( |secs| self . t . tv_sec . checked_add ( secs) )
54- {
55- Some ( ts) => ts,
56- None => return None ,
57- } ;
53+ . and_then ( |secs| self . t . tv_sec . checked_add ( secs) ) ?;
5854
5955 // Nano calculations can't overflow because nanos are <1B which fit
6056 // in a u32.
6157 let mut nsec = other. subsec_nanos ( ) + self . t . tv_nsec as u32 ;
6258 if nsec >= NSEC_PER_SEC as u32 {
6359 nsec -= NSEC_PER_SEC as u32 ;
64- secs = match secs. checked_add ( 1 ) {
65- Some ( ts) => ts,
66- None => return None ,
67- }
60+ secs = secs. checked_add ( 1 ) ?;
6861 }
6962 Some ( Timespec {
7063 t : syscall:: TimeSpec {
Original file line number Diff line number Diff line change @@ -47,25 +47,18 @@ impl Timespec {
4747 }
4848
4949 fn checked_add_duration ( & self , other : & Duration ) -> Option < Timespec > {
50- let mut secs = match other
50+ let mut secs = other
5151 . as_secs ( )
5252 . try_into ( ) // <- target type would be `libc::time_t`
5353 . ok ( )
54- . and_then ( |secs| self . t . tv_sec . checked_add ( secs) )
55- {
56- Some ( ts) => ts,
57- None => return None ,
58- } ;
54+ . and_then ( |secs| self . t . tv_sec . checked_add ( secs) ) ?;
5955
6056 // Nano calculations can't overflow because nanos are <1B which fit
6157 // in a u32.
6258 let mut nsec = other. subsec_nanos ( ) + self . t . tv_nsec as u32 ;
6359 if nsec >= NSEC_PER_SEC as u32 {
6460 nsec -= NSEC_PER_SEC as u32 ;
65- secs = match secs. checked_add ( 1 ) {
66- Some ( ts) => ts,
67- None => return None ,
68- }
61+ secs = secs. checked_add ( 1 ) ?;
6962 }
7063 Some ( Timespec {
7164 t : libc:: timespec {
You can’t perform that action at this time.
0 commit comments