Skip to content

Commit 492826a

Browse files
committed
Add a note about the panic behavior of math operations on time objects
1 parent 04f44fb commit 492826a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

library/std/src/time.rs

+10
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ pub use core::time::Duration;
100100
/// [clock_time_get (Monotonic Clock)]: https://nuxi.nl/cloudabi/#clock_time_get
101101
///
102102
/// **Disclaimer:** These system calls might change over time.
103+
///
104+
/// > Note: mathematical operations like [`add`] may panic if the underlying
105+
/// > structure cannot represent the new point in time.
106+
///
107+
/// [`add`]: Instant::add
103108
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
104109
#[stable(feature = "time2", since = "1.8.0")]
105110
pub struct Instant(time::Instant);
@@ -174,6 +179,11 @@ pub struct Instant(time::Instant);
174179
/// [GetSystemTimeAsFileTime]: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime
175180
///
176181
/// **Disclaimer:** These system calls might change over time.
182+
///
183+
/// > Note: mathematical operations like [`add`] may panic if the underlying
184+
/// > structure cannot represent the new point in time.
185+
///
186+
/// [`add`]: SystemTime::add
177187
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
178188
#[stable(feature = "time2", since = "1.8.0")]
179189
pub struct SystemTime(time::SystemTime);

0 commit comments

Comments
 (0)