@@ -73,7 +73,7 @@ impl Duration {
7373 /// ```
7474 #[ stable( feature = "duration" , since = "1.3.0" ) ]
7575 #[ inline]
76- pub fn new ( secs : u64 , nanos : u32 ) -> Duration {
76+ pub const fn new ( secs : u64 , nanos : u32 ) -> Duration {
7777 let secs = secs. checked_add ( ( nanos / NANOS_PER_SEC ) as u64 )
7878 . expect ( "overflow in Duration::new" ) ;
7979 let nanos = nanos % NANOS_PER_SEC ;
@@ -94,7 +94,7 @@ impl Duration {
9494 /// ```
9595 #[ stable( feature = "duration" , since = "1.3.0" ) ]
9696 #[ inline]
97- pub fn from_secs ( secs : u64 ) -> Duration {
97+ pub const fn from_secs ( secs : u64 ) -> Duration {
9898 Duration { secs : secs, nanos : 0 }
9999 }
100100
@@ -112,7 +112,7 @@ impl Duration {
112112 /// ```
113113 #[ stable( feature = "duration" , since = "1.3.0" ) ]
114114 #[ inline]
115- pub fn from_millis ( millis : u64 ) -> Duration {
115+ pub const fn from_millis ( millis : u64 ) -> Duration {
116116 let secs = millis / MILLIS_PER_SEC ;
117117 let nanos = ( ( millis % MILLIS_PER_SEC ) as u32 ) * NANOS_PER_MILLI ;
118118 Duration { secs : secs, nanos : nanos }
@@ -133,7 +133,7 @@ impl Duration {
133133 /// ```
134134 #[ unstable( feature = "duration_from_micros" , issue = "44400" ) ]
135135 #[ inline]
136- pub fn from_micros ( micros : u64 ) -> Duration {
136+ pub const fn from_micros ( micros : u64 ) -> Duration {
137137 let secs = micros / MICROS_PER_SEC ;
138138 let nanos = ( ( micros % MICROS_PER_SEC ) as u32 ) * NANOS_PER_MICRO ;
139139 Duration { secs : secs, nanos : nanos }
@@ -154,7 +154,7 @@ impl Duration {
154154 /// ```
155155 #[ unstable( feature = "duration_extras" , issue = "46507" ) ]
156156 #[ inline]
157- pub fn from_nanos ( nanos : u64 ) -> Duration {
157+ pub const fn from_nanos ( nanos : u64 ) -> Duration {
158158 let secs = nanos / ( NANOS_PER_SEC as u64 ) ;
159159 let nanos = ( nanos % ( NANOS_PER_SEC as u64 ) ) as u32 ;
160160 Duration { secs : secs, nanos : nanos }
0 commit comments