mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 03:38:29 +00:00
Remove Duration::MIN entirely
Duration::ZERO supercedes it in effect.
This commit is contained in:
parent
af4d1786e7
commit
82f3a236cd
@ -123,19 +123,6 @@ impl Duration {
|
|||||||
#[unstable(feature = "duration_zero", issue = "73544")]
|
#[unstable(feature = "duration_zero", issue = "73544")]
|
||||||
pub const ZERO: Duration = Duration::from_nanos(0);
|
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.
|
/// The maximum duration.
|
||||||
///
|
///
|
||||||
/// It is roughly equal to a duration of 584,942,417,355 years.
|
/// It is roughly equal to a duration of 584,942,417,355 years.
|
||||||
@ -533,18 +520,18 @@ 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.
|
/// if the result would be negative or if overflow occurred.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(duration_saturating_ops)]
|
/// #![feature(duration_saturating_ops)]
|
||||||
/// #![feature(duration_constants)]
|
/// #![feature(duration_zero)]
|
||||||
/// use std::time::Duration;
|
/// 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, 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")]
|
#[unstable(feature = "duration_saturating_ops", issue = "76416")]
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -552,7 +539,7 @@ impl Duration {
|
|||||||
pub const fn saturating_sub(self, rhs: Duration) -> Duration {
|
pub const fn saturating_sub(self, rhs: Duration) -> Duration {
|
||||||
match self.checked_sub(rhs) {
|
match self.checked_sub(rhs) {
|
||||||
Some(res) => res,
|
Some(res) => res,
|
||||||
None => Duration::MIN,
|
None => Duration::ZERO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user