about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexis Bourget <alexis.bourget@gmail.com>2020-06-15 15:19:02 +0200
committerAlexis Bourget <alexis.bourget@gmail.com>2020-06-15 15:19:02 +0200
commit9e510085ecaedaee86b44410a4b3e4c85d97d6e0 (patch)
tree2062c877a31e55cab9edca7a1d2a7b8f7463bf0a
parentf6072cab136beea206b7cfe79f8d10fccf5af591 (diff)
downloadrust-9e510085ecaedaee86b44410a4b3e4c85d97d6e0.tar.gz
rust-9e510085ecaedaee86b44410a4b3e4c85d97d6e0.zip
Complete the std::time documentation to warn about the inconsistencies between OS
-rw-r--r--src/libstd/time.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libstd/time.rs b/src/libstd/time.rs
index c36e78b1d00..c58168bd446 100644
--- a/src/libstd/time.rs
+++ b/src/libstd/time.rs
@@ -60,6 +60,21 @@ pub use core::time::Duration;
 /// }
 /// ```
 ///
+/// # OS-specific behaviors
+///
+/// An `Instant` is a wrapper around system-specific types and it may behave
+/// differently depending on the underlying operating system. For example,
+/// the following snippet is fine on Linux but panics on macOS:
+///
+/// ```no_run
+/// use std::time::{Instant, Duration};
+///
+/// let now = Instant::now();
+/// let max_nanoseconds = u64::MAX / 1_000_000_000;
+/// let duration = Duration::new(max_nanoseconds, 0);
+/// println!("{:?}", now + duration);
+/// ```
+///
 /// # Underlying System calls
 /// Currently, the following system calls are being used to get the current time using `now()`:
 ///