File tree Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -45,3 +45,6 @@ panic = "abort"
45
45
opt-level = 3
46
46
codegen-units = 1
47
47
incremental = false
48
+
49
+ [profile .dev ]
50
+ overflow-checks =true
Original file line number Diff line number Diff line change 1
1
#[ inline]
2
2
pub fn _sec_to_u64 ( sec : u64 ) -> u64 {
3
- sec << 32
3
+ sec. saturating_mul ( 1 << 32 )
4
4
}
5
5
6
6
#[ inline]
7
7
pub fn _millis_to_u64 ( millis : u64 ) -> u64 {
8
8
let secs = millis / 1_000 ;
9
- ( secs << 32 ) | ( ( millis - secs * 1_000 ) << 22 )
9
+ secs. saturating_mul ( 1 << 32 ) | ( ( millis - secs * 1_000 ) << 22 )
10
10
}
11
11
12
12
#[ inline]
@@ -17,10 +17,10 @@ pub fn _nsecs_to_u64(nsecs: u64) -> u64 {
17
17
18
18
#[ inline]
19
19
pub fn _timespec_to_u64 ( tp_sec : u64 , tp_nsec : u32 ) -> u64 {
20
- ( tp_sec << 32 ) | ( ( tp_nsec as u64 * 9_223_372_037 ) >> 31 )
20
+ tp_sec. saturating_mul ( 1 << 32 ) | ( ( tp_nsec as u64 * 9_223_372_037 ) >> 31 )
21
21
}
22
22
23
23
#[ inline]
24
24
pub fn _timeval_to_u64 ( tv_sec : u64 , tv_usec : u32 ) -> u64 {
25
- ( tv_sec << 32 ) | ( ( tv_usec as u64 * 9_223_372_036_855 ) >> 31 )
25
+ tv_sec. saturating_mul ( 1 << 32 ) | ( ( tv_usec as u64 * 9_223_372_036_855 ) >> 31 )
26
26
}
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ fn tests() {
32
32
}
33
33
34
34
#[ cfg( not( any( target_arch = "wasm32" , target_arch = "wasm64" ) ) ) ]
35
+ #[ test]
35
36
fn tests_updater ( ) {
36
37
let updater = Updater :: new ( 250 )
37
38
. start ( )
@@ -45,6 +46,11 @@ fn tests_updater() {
45
46
let ts = Instant :: recent ( ) ;
46
47
let clock_recent = Clock :: recent_since_epoch ( ) ;
47
48
sleep ( time:: Duration :: new ( 1 , 0 ) ) ;
48
- assert_eq ! ( Instant :: recent( ) , ts) ;
49
49
assert_eq ! ( Clock :: recent_since_epoch( ) , clock_recent) ;
50
50
}
51
+
52
+ #[ test]
53
+ fn tests_duration ( ) {
54
+ let duration = Duration :: from_days ( 1000 ) ;
55
+ assert_eq ! ( duration. as_days( ) , 1000 ) ;
56
+ }
You can’t perform that action at this time.
0 commit comments