Skip to content

Commit

Permalink
Remove Duration::MIN entirely
Browse files Browse the repository at this point in the history
Duration::ZERO supercedes it in effect.
  • Loading branch information
workingjubilee committed Oct 27, 2020
1 parent af4d178 commit 82f3a23
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions library/core/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,6 @@ impl Duration {
#[unstable(feature = "duration_zero", issue = "73544")]
pub const ZERO: Duration = Duration::from_nanos(0);

/// The minimum duration.
///
/// # Examples
///
/// ```
/// #![feature(duration_constants)]
/// use std::time::Duration;
///
/// assert_eq!(Duration::MIN, Duration::new(0, 0));
/// ```
#[unstable(feature = "duration_constants", issue = "57391")]
pub const MIN: Duration = Duration::from_nanos(0);

/// The maximum duration.
///
/// It is roughly equal to a duration of 584,942,417,355 years.
Expand Down Expand Up @@ -533,26 +520,26 @@ impl Duration {
}
}

/// Saturating `Duration` subtraction. Computes `self - other`, returning [`Duration::MIN`]
/// Saturating `Duration` subtraction. Computes `self - other`, returning [`Duration::ZERO`]
/// if the result would be negative or if overflow occurred.
///
/// # Examples
///
/// ```
/// #![feature(duration_saturating_ops)]
/// #![feature(duration_constants)]
/// #![feature(duration_zero)]
/// use std::time::Duration;
///
/// assert_eq!(Duration::new(0, 1).saturating_sub(Duration::new(0, 0)), Duration::new(0, 1));
/// assert_eq!(Duration::new(0, 0).saturating_sub(Duration::new(0, 1)), Duration::MIN);
/// assert_eq!(Duration::new(0, 0).saturating_sub(Duration::new(0, 1)), Duration::ZERO);
/// ```
#[unstable(feature = "duration_saturating_ops", issue = "76416")]
#[inline]
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn saturating_sub(self, rhs: Duration) -> Duration {
match self.checked_sub(rhs) {
Some(res) => res,
None => Duration::MIN,
None => Duration::ZERO,
}
}

Expand Down

0 comments on commit 82f3a23

Please sign in to comment.