]> git.lizzy.rs Git - rust.git/commitdiff
Turn duration consts into associated consts
authorStjepan Glavina <stjepang@gmail.com>
Wed, 20 Feb 2019 13:21:15 +0000 (14:21 +0100)
committerStjepan Glavina <stjepang@gmail.com>
Wed, 20 Feb 2019 13:21:15 +0000 (14:21 +0100)
src/libcore/time.rs
src/libstd/time.rs

index a751965dffab34ac31084fa9a3cfc0cb23b87cae..62ed8d6f7906aa95cfa7d655441113b96a11ec79 100644 (file)
 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;
 
-/// The duration of one second.
-#[unstable(feature = "duration_constants", issue = "57391")]
-pub const SECOND: Duration = Duration::from_secs(1);
-
-/// The duration of one millisecond.
-#[unstable(feature = "duration_constants", issue = "57391")]
-pub const MILLISECOND: Duration = Duration::from_millis(1);
-
-/// The duration of one microsecond.
-#[unstable(feature = "duration_constants", issue = "57391")]
-pub const MICROSECOND: Duration = Duration::from_micros(1);
-
-/// The duration of one nanosecond.
-#[unstable(feature = "duration_constants", issue = "57391")]
-pub const NANOSECOND: Duration = Duration::from_nanos(1);
-
 /// A `Duration` type to represent a span of time, typically used for system
 /// timeouts.
 ///
@@ -75,6 +59,22 @@ pub struct Duration {
 }
 
 impl Duration {
+    /// The duration of one second.
+    #[unstable(feature = "duration_constants", issue = "57391")]
+    pub const SECOND: Duration = Duration::from_secs(1);
+
+    /// The duration of one millisecond.
+    #[unstable(feature = "duration_constants", issue = "57391")]
+    pub const MILLISECOND: Duration = Duration::from_millis(1);
+
+    /// The duration of one microsecond.
+    #[unstable(feature = "duration_constants", issue = "57391")]
+    pub const MICROSECOND: Duration = Duration::from_micros(1);
+
+    /// The duration of one nanosecond.
+    #[unstable(feature = "duration_constants", issue = "57391")]
+    pub const NANOSECOND: Duration = Duration::from_nanos(1);
+
     /// Creates a new `Duration` from the specified number of whole seconds and
     /// additional nanoseconds.
     ///
index 507ea395c6c6c409d15b0be4ec40bb370f9d115b..72a5a070233e1fc6903c41d8af95b14b028bf0b4 100644 (file)
@@ -23,9 +23,6 @@
 #[stable(feature = "time", since = "1.3.0")]
 pub use core::time::Duration;
 
-#[unstable(feature = "duration_constants", issue = "57391")]
-pub use core::time::{SECOND, MILLISECOND, MICROSECOND, NANOSECOND};
-
 /// A measurement of a monotonically nondecreasing clock.
 /// Opaque and useful only with `Duration`.
 ///