@@ -36,34 +36,23 @@ impl SystemTime {
36
36
SystemTime ( Duration :: new ( now. seconds , now. nanoseconds ) )
37
37
}
38
38
39
- #[ rustc_const_unstable( feature = "const_system_time" , issue = "144517" ) ]
40
- pub const fn from_wasi_timestamp ( ts : wasi:: Timestamp ) -> SystemTime {
39
+ pub fn from_wasi_timestamp ( ts : wasi:: Timestamp ) -> SystemTime {
41
40
SystemTime ( Duration :: from_nanos ( ts) )
42
41
}
43
42
44
- #[ rustc_const_unstable( feature = "const_system_time" , issue = "144517" ) ]
45
- pub const fn to_wasi_timestamp ( & self ) -> Option < wasi:: Timestamp > {
46
- // FIXME: const TryInto
47
- let ns = self . 0 . as_nanos ( ) ;
48
- if ns <= u64:: MAX as u128 { Some ( ns as u64 ) } else { None }
43
+ pub fn to_wasi_timestamp ( & self ) -> Option < wasi:: Timestamp > {
44
+ self . 0 . as_nanos ( ) . try_into ( ) . ok ( )
49
45
}
50
46
51
- #[ rustc_const_unstable( feature = "const_system_time" , issue = "144517" ) ]
52
- pub const fn sub_time ( & self , other : & SystemTime ) -> Result < Duration , Duration > {
53
- // FIXME: ok_or_else with const closures
54
- match self . 0 . checked_sub ( other. 0 ) {
55
- Some ( duration) => Ok ( duration) ,
56
- None => Err ( other. 0 - self . 0 ) ,
57
- }
47
+ pub fn sub_time ( & self , other : & SystemTime ) -> Result < Duration , Duration > {
48
+ self . 0 . checked_sub ( other. 0 ) . ok_or_else ( || other. 0 - self . 0 )
58
49
}
59
50
60
- #[ rustc_const_unstable( feature = "const_system_time" , issue = "144517" ) ]
61
- pub const fn checked_add_duration ( & self , other : & Duration ) -> Option < SystemTime > {
51
+ pub fn checked_add_duration ( & self , other : & Duration ) -> Option < SystemTime > {
62
52
Some ( SystemTime ( self . 0 . checked_add ( * other) ?) )
63
53
}
64
54
65
- #[ rustc_const_unstable( feature = "const_system_time" , issue = "144517" ) ]
66
- pub const fn checked_sub_duration ( & self , other : & Duration ) -> Option < SystemTime > {
55
+ pub fn checked_sub_duration ( & self , other : & Duration ) -> Option < SystemTime > {
67
56
Some ( SystemTime ( self . 0 . checked_sub ( * other) ?) )
68
57
}
69
58
}
0 commit comments