Skip to content

Commit 8367944

Browse files
authored
Rollup merge of #157703 - orlp:fix-instant-comment, r=SimonSapin
Fix doc link to Instant sub in saturating caveat The `sub` link in the caveat about saturating subtraction for `Instant` was linking to the wrong implementation of `sub`. On https://doc.rust-lang.org/std/time/struct.Instant.html it was linking to `Instant - Duration` which in fact *is not saturating*, and *will* panic. It should link to `Instant - Instant`.
2 parents b43c6e9 + 6a0f2d4 commit 8367944

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

library/std/src/time.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ use crate::sys::{FromInner, IntoInner, time};
137137
/// if available, which is the case for all [tier 1] platforms.
138138
/// In practice such guarantees are – under rare circumstances – broken by hardware, virtualization
139139
/// or operating system bugs. To work around these bugs and platforms not offering monotonic clocks
140-
/// [`duration_since`], [`elapsed`] and [`sub`] saturate to zero. In older Rust versions this
141-
/// lead to a panic instead. [`checked_duration_since`] can be used to detect and handle situations
142-
/// where monotonicity is violated, or `Instant`s are subtracted in the wrong order.
140+
/// [`duration_since`], [`elapsed`] and [`sub`](#impl-Sub-for-Instant) saturate to zero. In older
141+
/// Rust versions this lead to a panic instead. [`checked_duration_since`] can be used to detect and
142+
/// handle situations where monotonicity is violated, or `Instant`s are subtracted in the wrong order.
143143
///
144144
/// This workaround obscures programming errors where earlier and later instants are accidentally
145145
/// swapped. For this reason future Rust versions may reintroduce panics.

0 commit comments

Comments
 (0)