From 5cdb962875271411a558ba29b0bfb630f633c102 Mon Sep 17 00:00:00 2001 From: Isaac Goldberg Date: Mon, 19 Apr 2021 14:01:42 -0700 Subject: [PATCH] Fix impl and docstring --- library/std/src/time.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library/std/src/time.rs b/library/std/src/time.rs index 89addae078948..8ca3b2ce4bf5e 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -323,9 +323,7 @@ impl Instant { /// Returns the amount of time elapsed since this instant was created. /// - /// # Panics - /// - /// This function may panic if the current time is earlier than this + /// Returns zero duration if the current time is earlier than this /// instant, which is something that can happen if an `Instant` is /// produced synthetically. /// @@ -342,7 +340,7 @@ impl Instant { /// ``` #[stable(feature = "time2", since = "1.8.0")] pub fn elapsed(&self) -> Duration { - Instant::now() - *self + Instant::now().saturating_duration_since(*self) } /// Returns `Some(t)` where `t` is the time `self + duration` if `t` can be represented as