Skip to content

Commit

Permalink
Revise according to review
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhoo committed Jun 20, 2020
1 parent ad7fd62 commit 386114b
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions src/libcore/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,24 @@ impl Duration {
Duration { secs, nanos }
}

/// Creates a new `Duration` that spans no time.
///
/// # Examples
///
/// ```
/// #![feature(duration_zero)]
/// use std::time::Duration;
///
/// let duration = Duration::zero();
/// assert!(duration.is_zero());
/// assert_eq!(duration.as_nanos(), 0);
/// ```
#[unstable(feature = "duration_zero", issue = "73544")]
#[inline]
pub const fn zero() -> Duration {
Duration { secs: 0, nanos: 0 }
}

/// Creates a new `Duration` from the specified number of whole seconds.
///
/// # Examples
Expand Down Expand Up @@ -223,26 +241,6 @@ impl Duration {
}
}

/// Creates a new `Duration` that spans no time.
///
/// # Examples
///
/// ```
/// #![feature(duration_zero)]
/// use std::time::Duration;
///
/// let duration = Duration::zero();
/// assert!(duration.is_zero());
///
/// const IMMEDIATELY: Duration = Duration::zero();
/// assert!(IMMEDIATELY.is_zero());
/// ```
#[unstable(feature = "duration_zero", issue = "none")]
#[inline]
pub const fn zero() -> Duration {
Duration { secs: 0, nanos: 0 }
}

/// Returns true if this `Duration` spans no time.
///
/// # Examples
Expand All @@ -260,7 +258,7 @@ impl Duration {
/// assert!(!Duration::from_nanos(1).is_zero());
/// assert!(!Duration::from_secs(1).is_zero());
/// ```
#[unstable(feature = "duration_zero", issue = "none")]
#[unstable(feature = "duration_zero", issue = "73544")]
#[inline]
pub const fn is_zero(&self) -> bool {
self.secs == 0 && self.nanos == 0
Expand Down

0 comments on commit 386114b

Please sign in to comment.