Skip to content

Commit f223c03

Browse files
author
Stjepan Glavina
committed
Add examples for duration constants
1 parent 8e219e7 commit f223c03

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/libcore/time.rs

+32
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,50 @@ pub struct Duration {
6060

6161
impl Duration {
6262
/// The duration of one second.
63+
///
64+
/// # Examples
65+
///
66+
/// ```
67+
/// use std::time::Duration;
68+
///
69+
/// assert_eq!(Duration::SECOND, Duration::from_secs(1));
70+
/// ```
6371
#[unstable(feature = "duration_constants", issue = "57391")]
6472
pub const SECOND: Duration = Duration::from_secs(1);
6573

6674
/// The duration of one millisecond.
75+
///
76+
/// # Examples
77+
///
78+
/// ```
79+
/// use std::time::Duration;
80+
///
81+
/// assert_eq!(Duration::MILLISECOND, Duration::from_millis(1));
82+
/// ```
6783
#[unstable(feature = "duration_constants", issue = "57391")]
6884
pub const MILLISECOND: Duration = Duration::from_millis(1);
6985

7086
/// The duration of one microsecond.
87+
///
88+
/// # Examples
89+
///
90+
/// ```
91+
/// use std::time::Duration;
92+
///
93+
/// assert_eq!(Duration::MICROSECOND, Duration::from_micros(1));
94+
/// ```
7195
#[unstable(feature = "duration_constants", issue = "57391")]
7296
pub const MICROSECOND: Duration = Duration::from_micros(1);
7397

7498
/// The duration of one nanosecond.
99+
///
100+
/// # Examples
101+
///
102+
/// ```
103+
/// use std::time::Duration;
104+
///
105+
/// assert_eq!(Duration::NANOSECOND, Duration::from_nanos(1));
106+
/// ```
75107
#[unstable(feature = "duration_constants", issue = "57391")]
76108
pub const NANOSECOND: Duration = Duration::from_nanos(1);
77109

0 commit comments

Comments
 (0)