]> git.lizzy.rs Git - rust.git/commitdiff
Complete the std::time documentation to warn about the inconsistencies between OS
authorAlexis Bourget <alexis.bourget@gmail.com>
Mon, 15 Jun 2020 13:19:02 +0000 (15:19 +0200)
committerAlexis Bourget <alexis.bourget@gmail.com>
Mon, 15 Jun 2020 13:19:02 +0000 (15:19 +0200)
src/libstd/time.rs

index c36e78b1d004e2bc02f4b4e21e274c4f3aae9fd9..c58168bd446d7e69ca3e74ed4813a418901f1d85 100644 (file)
 /// }
 /// ```
 ///
+/// # 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()`:
 ///