File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 1- use std:: { ffi:: OsString , time:: Duration } ;
1+ use std:: ffi:: OsString ;
2+ use std:: time:: Duration ;
23
34use crate :: common:: context:: LaunchType ;
45use crate :: common:: error:: Error ;
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ use crate::system::{Hostname, User};
1212///
1313/// The trait definitions can be part of some global crate in the future, if we support more
1414/// than just the sudoers file.
15- use std:: { collections:: HashSet , time:: Duration } ;
15+ use std:: collections:: HashSet ;
16+ use std:: time:: Duration ;
1617
1718#[ must_use]
1819#[ cfg_attr( test, derive( Debug , PartialEq ) ) ]
@@ -191,7 +192,7 @@ mod test {
191192 Authentication {
192193 must_authenticate: true ,
193194 allowed_attempts: 3 ,
194- prior_validity: Duration :: from_secs ( 15 * 60 ) ,
195+ prior_validity: Duration :: from_mins ( 15 ) ,
195196 credential: AuthenticatingUser :: InvokingUser ,
196197 pwfeedback: false ,
197198 password_timeout: Some ( Duration :: from_secs( 300 ) ) ,
Original file line number Diff line number Diff line change @@ -54,9 +54,9 @@ impl SystemTime {
5454 }
5555
5656 #[ inline]
57- pub fn checked_add ( self , rhs : Duration ) -> Option < SystemTime > {
58- let rhs_secs = rhs. as_nanos ( ) . div_euclid ( 1_000_000_000 ) . try_into ( ) . ok ( ) ?;
59- let rhs_nsecs = rhs. as_nanos ( ) . rem_euclid ( 1_000_000_000 ) . try_into ( ) . ok ( ) ?;
57+ fn checked_add ( self , rhs : Duration ) -> Option < SystemTime > {
58+ let rhs_secs = rhs. as_secs ( ) . try_into ( ) . ok ( ) ?;
59+ let rhs_nsecs = rhs. subsec_nanos ( ) . try_into ( ) . ok ( ) ?;
6060
6161 let secs = self . secs . checked_add ( rhs_secs) ?;
6262 let nsecs = self . nsecs . checked_add ( rhs_nsecs) ?;
@@ -65,9 +65,9 @@ impl SystemTime {
6565 }
6666
6767 #[ inline]
68- pub fn checked_sub ( self , rhs : Duration ) -> Option < SystemTime > {
69- let rhs_secs = rhs. as_nanos ( ) . div_euclid ( 1_000_000_000 ) . try_into ( ) . ok ( ) ?;
70- let rhs_nsecs = rhs. as_nanos ( ) . rem_euclid ( 1_000_000_000 ) . try_into ( ) . ok ( ) ?;
68+ fn checked_sub ( self , rhs : Duration ) -> Option < SystemTime > {
69+ let rhs_secs = rhs. as_secs ( ) . try_into ( ) . ok ( ) ?;
70+ let rhs_nsecs = rhs. subsec_nanos ( ) . try_into ( ) . ok ( ) ?;
7171
7272 let secs = self . secs . checked_sub ( rhs_secs) ?;
7373 let nsecs = self . nsecs . checked_sub ( rhs_nsecs) ?;
You can’t perform that action at this time.
0 commit comments