Commit f2106d0 1 parent 86ef38b commit f2106d0 Copy full SHA for f2106d0
File tree 2 files changed +6
-20
lines changed
2 files changed +6
-20
lines changed Original file line number Diff line number Diff line change @@ -46,25 +46,18 @@ impl Timespec {
46
46
}
47
47
48
48
fn checked_add_duration ( & self , other : & Duration ) -> Option < Timespec > {
49
- let mut secs = match other
49
+ let mut secs = other
50
50
. as_secs ( )
51
51
. try_into ( ) // <- target type would be `i64`
52
52
. 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) ) ?;
58
54
59
55
// Nano calculations can't overflow because nanos are <1B which fit
60
56
// in a u32.
61
57
let mut nsec = other. subsec_nanos ( ) + self . t . tv_nsec as u32 ;
62
58
if nsec >= NSEC_PER_SEC as u32 {
63
59
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 ) ?;
68
61
}
69
62
Some ( Timespec {
70
63
t : syscall:: TimeSpec {
Original file line number Diff line number Diff line change @@ -47,25 +47,18 @@ impl Timespec {
47
47
}
48
48
49
49
fn checked_add_duration ( & self , other : & Duration ) -> Option < Timespec > {
50
- let mut secs = match other
50
+ let mut secs = other
51
51
. as_secs ( )
52
52
. try_into ( ) // <- target type would be `libc::time_t`
53
53
. 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) ) ?;
59
55
60
56
// Nano calculations can't overflow because nanos are <1B which fit
61
57
// in a u32.
62
58
let mut nsec = other. subsec_nanos ( ) + self . t . tv_nsec as u32 ;
63
59
if nsec >= NSEC_PER_SEC as u32 {
64
60
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 ) ?;
69
62
}
70
63
Some ( Timespec {
71
64
t : libc:: timespec {
You can’t perform that action at this time.
0 commit comments