about summary refs log tree commit diff
path: root/src/libcore/time.rs
diff options
context:
space:
mode:
authornewpavlov <newpavlov@gmail.com>2019-03-11 18:06:13 +0300
committernewpavlov <newpavlov@gmail.com>2019-03-11 18:06:13 +0300
commit35c19c5b3d1fe8675132ea96e014e37455653ce8 (patch)
treead62000a1f0e604a57547aa2185cfbdcd84518b6 /src/libcore/time.rs
parente25df326caf38c1a8559fc6fa633ad60ab401e12 (diff)
downloadrust-35c19c5b3d1fe8675132ea96e014e37455653ce8.tar.gz
rust-35c19c5b3d1fe8675132ea96e014e37455653ce8.zip
move MAX_NANOS_F64/32 to methods
Diffstat (limited to 'src/libcore/time.rs')
-rw-r--r--src/libcore/time.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libcore/time.rs b/src/libcore/time.rs
index c8f23fd90bd..d3f80835c01 100644
--- a/src/libcore/time.rs
+++ b/src/libcore/time.rs
@@ -21,8 +21,6 @@ const NANOS_PER_MILLI: u32 = 1_000_000;
 const NANOS_PER_MICRO: u32 = 1_000;
 const MILLIS_PER_SEC: u64 = 1_000;
 const MICROS_PER_SEC: u64 = 1_000_000;
-const MAX_NANOS_F64: f64 = ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64;
-const MAX_NANOS_F32: f64 = ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f32;
 
 /// A `Duration` type to represent a span of time, typically used for system
 /// timeouts.
@@ -554,6 +552,8 @@ impl Duration {
     #[unstable(feature = "duration_float", issue = "54361")]
     #[inline]
     pub fn from_secs_f64(secs: f64) -> Duration {
+        const MAX_NANOS_F64: f64 =
+            ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64;
         let nanos =  secs * (NANOS_PER_SEC as f64);
         if !nanos.is_finite() {
             panic!("got non-finite value when converting float to duration");
@@ -588,6 +588,8 @@ impl Duration {
     #[unstable(feature = "duration_float", issue = "54361")]
     #[inline]
     pub fn from_secs_f32(secs: f32) -> Duration {
+        const MAX_NANOS_F32: f32 =
+            ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f32;
         let nanos =  secs * (NANOS_PER_SEC as f32);
         if !nanos.is_finite() {
             panic!("got non-finite value when converting float to duration");