Feature request: time::now #62114
Labels
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
Preface: this is the first time I'm filing an issue on
rust-lang/rust
. This is a feature request that also seems too small for an RFC. The contrib guidelines are not too clear what to do here, so I hope I'm doing this right.Motivation
In #57391 there's been conversation about making it easier to construct new
time::Duration
s by using constants:While writing code today I was wondering about easier ways to create
Instant
s. Specifically creating a timestamp that evaluates to now would be useful. As it could be combined with the constants to create anInstant
at a particular point in the future.This is why I would like to propose the addition of a
time::now
function that would be equivalent totime::Instant::now
. The result would be for most programs only the top-levelstd::time
module needs to be imported, and lines dealing with time-related code would be fewer to express the same results.Thanks!
Examples
Adapted from the
time::Instant
docs.Proposed
Current
edit: I've written a post on this: https://blog.yoshuawuyts.com/std-time/
The text was updated successfully, but these errors were encountered: