diff options
| author | bors <bors@rust-lang.org> | 2019-07-28 20:22:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-07-28 20:22:42 +0000 |
| commit | c7312fe4ff85ada30103cea58db25d83e0bec4b0 (patch) | |
| tree | c45aed285c4e04591ea7d6e8bc6c90b3461671a6 /src/libstd | |
| parent | 4560cb830fce63fcffdc4558f4281aaac6a3a1ba (diff) | |
| parent | 29c377882f545e24b9cc6e1198ee4f72c20d5449 (diff) | |
| download | rust-c7312fe4ff85ada30103cea58db25d83e0bec4b0.tar.gz rust-c7312fe4ff85ada30103cea58db25d83e0bec4b0.zip | |
Auto merge of #63090 - Centril:rollup-xnjwm2h, r=Centril
Rollup of 8 pull requests Successful merges: - #61856 (Lint attributes on function arguments) - #62360 (Document that ManuallyDrop::drop should not called more than once) - #62392 (Update minifier-rs version) - #62871 (Explicit error message for async recursion.) - #62995 (Avoid ICE when suggestion span is at Eof) - #63053 (SystemTime docs: recommend Instant for elapsed time) - #63081 (tidy: Cleanup the directory whitelist) - #63088 (Remove anonymous_parameters from unrelated test) Failed merges: r? @ghost
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/time.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libstd/time.rs b/src/libstd/time.rs index dc97f8c04a8..98371b9ba3d 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -396,6 +396,7 @@ impl SystemTime { /// This function may fail because measurements taken earlier are not /// guaranteed to always be before later measurements (due to anomalies such /// as the system clock being adjusted either forwards or backwards). + /// [`Instant`] can be used to measure elapsed time without this risk of failure. /// /// If successful, [`Ok`]`(`[`Duration`]`)` is returned where the duration represents /// the amount of time elapsed from the specified measurement to this one. @@ -406,6 +407,7 @@ impl SystemTime { /// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok /// [`Duration`]: ../../std/time/struct.Duration.html /// [`Err`]: ../../std/result/enum.Result.html#variant.Err + /// [`Instant`]: ../../std/time/struct.Instant.html /// /// # Examples /// @@ -414,7 +416,7 @@ impl SystemTime { /// /// let sys_time = SystemTime::now(); /// let difference = sys_time.duration_since(sys_time) - /// .expect("SystemTime::duration_since failed"); + /// .expect("Clock may have gone backwards"); /// println!("{:?}", difference); /// ``` #[stable(feature = "time2", since = "1.8.0")] @@ -423,7 +425,8 @@ impl SystemTime { self.0.sub_time(&earlier.0).map_err(SystemTimeError) } - /// Returns the amount of time elapsed since this system time was created. + /// Returns the difference between the clock time when this + /// system time was created, and the current clock time. /// /// This function may fail as the underlying system clock is susceptible to /// drift and updates (e.g., the system clock could go backwards), so this @@ -431,12 +434,15 @@ impl SystemTime { /// returned where the duration represents the amount of time elapsed from /// this time measurement to the current time. /// + /// To measure elapsed time reliably, use [`Instant`] instead. + /// /// Returns an [`Err`] if `self` is later than the current system time, and /// the error contains how far from the current system time `self` is. /// /// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok /// [`Duration`]: ../../std/time/struct.Duration.html /// [`Err`]: ../../std/result/enum.Result.html#variant.Err + /// [`Instant`]: ../../std/time/struct.Instant.html /// /// # Examples /// |
