Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions library/std/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -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
Expand Down