From f223c03372f198d4fc50960288fc033f9de5da10 Mon Sep 17 00:00:00 2001 From: Stjepan Glavina Date: Wed, 20 Feb 2019 21:58:20 +0100 Subject: [PATCH] Add examples for duration constants --- src/libcore/time.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/libcore/time.rs b/src/libcore/time.rs index 62ed8d6f790..a28f690775b 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -60,18 +60,50 @@ pub struct Duration { impl Duration { /// The duration of one second. + /// + /// # Examples + /// + /// ``` + /// use std::time::Duration; + /// + /// assert_eq!(Duration::SECOND, Duration::from_secs(1)); + /// ``` #[unstable(feature = "duration_constants", issue = "57391")] pub const SECOND: Duration = Duration::from_secs(1); /// The duration of one millisecond. + /// + /// # Examples + /// + /// ``` + /// use std::time::Duration; + /// + /// assert_eq!(Duration::MILLISECOND, Duration::from_millis(1)); + /// ``` #[unstable(feature = "duration_constants", issue = "57391")] pub const MILLISECOND: Duration = Duration::from_millis(1); /// The duration of one microsecond. + /// + /// # Examples + /// + /// ``` + /// use std::time::Duration; + /// + /// assert_eq!(Duration::MICROSECOND, Duration::from_micros(1)); + /// ``` #[unstable(feature = "duration_constants", issue = "57391")] pub const MICROSECOND: Duration = Duration::from_micros(1); /// The duration of one nanosecond. + /// + /// # Examples + /// + /// ``` + /// use std::time::Duration; + /// + /// assert_eq!(Duration::NANOSECOND, Duration::from_nanos(1)); + /// ``` #[unstable(feature = "duration_constants", issue = "57391")] pub const NANOSECOND: Duration = Duration::from_nanos(1);