about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNathaniel Ringo <remexre@gmail.com>2018-01-09 14:21:45 -0600
committerNathaniel Ringo <remexre@gmail.com>2018-01-09 14:21:45 -0600
commit2624c05acf93ca2b35dae7ae3770fd92b5dce4b5 (patch)
tree503b9f4ec3b8b1bcaecc86b6349431942e40e7f4
parent61452e506f0c88861cccaeea4ced3419bdb3cbe0 (diff)
downloadrust-2624c05acf93ca2b35dae7ae3770fd92b5dce4b5.tar.gz
rust-2624c05acf93ca2b35dae7ae3770fd92b5dce4b5.zip
Makes the constructors of Duration const fns.
-rw-r--r--src/libstd/time/duration.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libstd/time/duration.rs b/src/libstd/time/duration.rs
index 15ddb62bab5..e0c90664119 100644
--- a/src/libstd/time/duration.rs
+++ b/src/libstd/time/duration.rs
@@ -73,7 +73,7 @@ impl Duration {
     /// ```
     #[stable(feature = "duration", since = "1.3.0")]
     #[inline]
-    pub fn new(secs: u64, nanos: u32) -> Duration {
+    pub const fn new(secs: u64, nanos: u32) -> Duration {
         let secs = secs.checked_add((nanos / NANOS_PER_SEC) as u64)
             .expect("overflow in Duration::new");
         let nanos = nanos % NANOS_PER_SEC;
@@ -94,7 +94,7 @@ impl Duration {
     /// ```
     #[stable(feature = "duration", since = "1.3.0")]
     #[inline]
-    pub fn from_secs(secs: u64) -> Duration {
+    pub const fn from_secs(secs: u64) -> Duration {
         Duration { secs: secs, nanos: 0 }
     }
 
@@ -112,7 +112,7 @@ impl Duration {
     /// ```
     #[stable(feature = "duration", since = "1.3.0")]
     #[inline]
-    pub fn from_millis(millis: u64) -> Duration {
+    pub const fn from_millis(millis: u64) -> Duration {
         let secs = millis / MILLIS_PER_SEC;
         let nanos = ((millis % MILLIS_PER_SEC) as u32) * NANOS_PER_MILLI;
         Duration { secs: secs, nanos: nanos }
@@ -133,7 +133,7 @@ impl Duration {
     /// ```
     #[unstable(feature = "duration_from_micros", issue = "44400")]
     #[inline]
-    pub fn from_micros(micros: u64) -> Duration {
+    pub const fn from_micros(micros: u64) -> Duration {
         let secs = micros / MICROS_PER_SEC;
         let nanos = ((micros % MICROS_PER_SEC) as u32) * NANOS_PER_MICRO;
         Duration { secs: secs, nanos: nanos }
@@ -154,7 +154,7 @@ impl Duration {
     /// ```
     #[unstable(feature = "duration_extras", issue = "46507")]
     #[inline]
-    pub fn from_nanos(nanos: u64) -> Duration {
+    pub const fn from_nanos(nanos: u64) -> Duration {
         let secs = nanos / (NANOS_PER_SEC as u64);
         let nanos = (nanos % (NANOS_PER_SEC as u64)) as u32;
         Duration { secs: secs, nanos: nanos }