about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2023-02-24 12:02:42 +0530
committerGitHub <noreply@github.com>2023-02-24 12:02:42 +0530
commitf94c3c9da19451a14202a7dcffe78e08d75fd9ce (patch)
tree3dd21bc244de5b87e513cb7dd2570a83bf130572
parent251293ef5e563b11fc7d46b6e1a31ef740f26455 (diff)
parentb54a5fdca0ec6241cb2592a1336c67d478632d03 (diff)
downloadrust-f94c3c9da19451a14202a7dcffe78e08d75fd9ce.tar.gz
rust-f94c3c9da19451a14202a7dcffe78e08d75fd9ce.zip
Rollup merge of #108370 - fbq:time-doc-fix, r=thomcc
std: time: Avoid to use "was created" in elapsed() description

".. since this instant was created" is inaccurate and misleading, consider the following case:
```rust
	let i1 = Instant::now(); // i1 is created at T1
	let i2 = i1 + Duration::from_nanos(0); // i2 is "created" at T2
	i2.elapsed(); // at T3
```
Per the current description, `elapsed()` at T3 should return T3 - T2?

To avoid the inaccuracy, removes the "was created" in the description of {Instant,SystemTime}::elapsed().
And since these types represent times, it's OK to use prepostions with them, e.g. "since this instant".
-rw-r--r--library/std/src/time.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/library/std/src/time.rs b/library/std/src/time.rs
index acf9c29083f..5c2e9da70fb 100644
--- a/library/std/src/time.rs
+++ b/library/std/src/time.rs
@@ -352,7 +352,7 @@ impl Instant {
         self.checked_duration_since(earlier).unwrap_or_default()
     }
 
-    /// Returns the amount of time elapsed since this instant was created.
+    /// Returns the amount of time elapsed since this instant.
     ///
     /// # Panics
     ///
@@ -525,8 +525,8 @@ impl SystemTime {
         self.0.sub_time(&earlier.0).map_err(SystemTimeError)
     }
 
-    /// Returns the difference between the clock time when this
-    /// system time was created, and the current clock time.
+    /// Returns the difference from this system time to 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