File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -43,11 +43,15 @@ const DAYS_PER_WEEK: u64 = 7;
4343#[ rustc_layout_scalar_valid_range_end( 999_999_999 ) ]
4444struct Nanoseconds ( u32 ) ;
4545
46+ impl Nanoseconds {
47+ // SAFETY: 0 is within the valid range
48+ const ZERO : Self = unsafe { Nanoseconds ( 0 ) } ;
49+ }
50+
4651impl Default for Nanoseconds {
4752 #[ inline]
4853 fn default ( ) -> Self {
49- // SAFETY: 0 is within the valid range
50- unsafe { Nanoseconds ( 0 ) }
54+ Self :: ZERO
5155 }
5256}
5357
@@ -236,7 +240,7 @@ impl Duration {
236240 #[ inline]
237241 #[ rustc_const_stable( feature = "duration_consts" , since = "1.32.0" ) ]
238242 pub const fn from_secs ( secs : u64 ) -> Duration {
239- Duration :: new ( secs, 0 )
243+ Duration { secs, nanos : Nanoseconds :: ZERO }
240244 }
241245
242246 /// Creates a new `Duration` from the specified number of milliseconds.
You can’t perform that action at this time.
0 commit comments