Revise according to review
This commit is contained in:
parent
ad7fd6265e
commit
386114bfd3
@ -138,6 +138,24 @@ pub fn new(secs: u64, nanos: u32) -> 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
|
||||
@ -223,26 +241,6 @@ pub const fn from_nanos(nanos: u64) -> 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
|
||||
@ -260,7 +258,7 @@ pub const fn zero() -> 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
|
||||
|
Loading…
Reference in New Issue
Block a user