Skip to content

Commit 1c0d6d1

Browse files
Clarify Duration::MAX depends on Instant
Duration is used in std to represent a difference between two Instants. As such, it has to at least contain that span of time in it. However, Instant can vary by platform. Thus, we should explain the impl of Duration::MAX is sensitive to these vagaries of the platform.
1 parent b976e94 commit 1c0d6d1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/src/time.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,18 @@ impl Duration {
136136

137137
/// The maximum duration.
138138
///
139-
/// It is roughly equal to a duration of 584,942,417,355 years.
139+
/// May vary by platform. At least equal to the number of seconds
140+
/// difference between the minimum and maximum [`std::time::Instant`].
141+
/// On many platforms this is roughly 584,942,417,355 years.
140142
///
141143
/// # Examples
142144
///
143145
/// ```
144-
/// #![feature(duration_constants)]
145146
/// use std::time::Duration;
146147
///
147148
/// assert_eq!(Duration::MAX, Duration::new(u64::MAX, 1_000_000_000 - 1));
148149
/// ```
150+
/// [`std::time::Instant`]: ../../std/time/struct.Instant.html
149151
#[stable(feature = "duration_saturating_ops", since = "1.53.0")]
150152
pub const MAX: Duration = Duration::new(u64::MAX, NANOS_PER_SEC - 1);
151153

0 commit comments

Comments
 (0)