Skip to content

Commit b54a5fd

Browse files
committed
std: time: Avoid to use "was created" in elapsed() description
".. since this instant was created" is inaccurate and misleading, consider the following case: 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? Therefore 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".
1 parent fdbc432 commit b54a5fd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

library/std/src/time.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ impl Instant {
352352
self.checked_duration_since(earlier).unwrap_or_default()
353353
}
354354

355-
/// Returns the amount of time elapsed since this instant was created.
355+
/// Returns the amount of time elapsed since this instant.
356356
///
357357
/// # Panics
358358
///
@@ -525,8 +525,8 @@ impl SystemTime {
525525
self.0.sub_time(&earlier.0).map_err(SystemTimeError)
526526
}
527527

528-
/// Returns the difference between the clock time when this
529-
/// system time was created, and the current clock time.
528+
/// Returns the difference from this system time to the
529+
/// current clock time.
530530
///
531531
/// This function may fail as the underlying system clock is susceptible to
532532
/// drift and updates (e.g., the system clock could go backwards), so this

0 commit comments

Comments
 (0)