Skip to content

Commit

Permalink
Add examples for duration constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Stjepan Glavina committed Feb 20, 2019
1 parent 8e219e7 commit f223c03
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/libcore/time.rs
Expand Up @@ -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);

Expand Down

0 comments on commit f223c03

Please sign in to comment.