rust-lang / rust-lang/rust

Deprecate `std::time::Instant::saturating_duration_since()`?

Open
#133,525 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-discussion T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

As previously suggested here: https://github.com/rust-lang/rust/pull/84448#issuecomment-944421516

Starting from #89926, std::time::Instant::duration_since() effectively does the same thing as the later introduced std::time::Instant::saturating_duration_since() (they are now literally identical). Given that this was a possibly breaking change that has already passed, I propose the latter function for deprecation and subsequent removal, as it currently creates the false ambiguity.

The only objection I see is that the current state of affairs allows to bring back panic! in the future, as mentioned in a comment here:
https://doc.rust-lang.org/1.82.0/src/std/time.rs.html#143-144

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading std/time.rs around lines 143-144 and the linked documentation for Instant::duration_since() and Instant::saturating_duration_since(), then review the linked historical discussion. Done means the deprecation and subsequent-removal proposal has an agreed resolution for the affected API.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.