Skip to content

Commit

Permalink
Rollup merge of rust-lang#84120 - workingjubilee:stabilize-duration-m…
Browse files Browse the repository at this point in the history
…ax, r=m-ou-se

Stabilize Duration::MAX

Following the suggested direction from rust-lang#76416 (comment), this PR proposes that `Duration::MAX` should have been part of the `duration_saturating_ops` feature flag all along, having been

0. heavily referenced by that feature flag
1. an odd duck next to most of `duration_constants`, as I expressed in rust-lang#57391 (comment)
2. introduced in rust-lang#76114 which added `duration_saturating_ops`

and accordingly should be folded into `duration_saturating_ops` and therefore stabilized.

r? `@m-ou-se`
  • Loading branch information
m-ou-se authored Apr 26, 2021
2 parents 154858c + 8278380 commit fb1502d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions library/core/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,21 @@ impl Duration {

/// The maximum duration.
///
/// It is roughly equal to a duration of 584,942,417,355 years.
/// May vary by platform as necessary. Must be able to contain the difference between
/// two instances of [`Instant`] or two instances of [`SystemTime`].
/// This constraint gives it a value of about 584,942,417,355 years in practice,
/// which is currently used on all platforms.
///
/// # Examples
///
/// ```
/// #![feature(duration_constants)]
/// use std::time::Duration;
///
/// assert_eq!(Duration::MAX, Duration::new(u64::MAX, 1_000_000_000 - 1));
/// ```
#[unstable(feature = "duration_constants", issue = "57391")]
/// [`Instant`]: ../../std/time/struct.Instant.html
/// [`SystemTime`]: ../../std/time/struct.SystemTime.html
#[stable(feature = "duration_saturating_ops", since = "1.53.0")]
pub const MAX: Duration = Duration::new(u64::MAX, NANOS_PER_SEC - 1);

/// Creates a new `Duration` from the specified number of whole seconds and
Expand Down

0 comments on commit fb1502d

Please sign in to comment.