Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize Duration::MAX #84120

Merged
merged 3 commits into from
Apr 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions library/core/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 136,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