-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add duration constants #57375
Add duration constants #57375
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
@bors r+ |
📌 Commit 72ec5aa has been approved by |
Shouldn't we create a tracking issue for this first? |
src/libcore/time.rs
Outdated
@@ -23,6 +23,22 @@ const MILLIS_PER_SEC: u64 = 1_000; | |||
const MICROS_PER_SEC: u64 = 1_000_000; | |||
const MAX_NANOS_F64: f64 = ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64; | |||
|
|||
/// The duration of one second. | |||
#[unstable(feature = "duration_constants", issue = "0")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue number should be updated for the tracking issue in all places where the issue is mentioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good call. @stjepang, can you please update those to reference the tracking issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@bors r- |
Thanks! @bors r+ |
📌 Commit 8c902b6 has been approved by |
…triplett Add duration constants Add constants `SECOND`, `MILLISECOND`, `MICROSECOND`, and `NANOSECOND` to `core::time`. This will make working with durations more ergonomic. Compare: ```rust // Convenient, but deprecated function. thread::sleep_ms(2000); // The current canonical way to sleep for two seconds. thread::sleep(Duration::from_secs(2)); // Sleeping using one of the new constants. thread::sleep(2 * SECOND); ```
Rollup of 6 pull requests Successful merges: - #57290 (remove outdated comment) - #57308 (Make CompileController thread-safe) - #57358 (use utf-8 throughout htmldocck) - #57369 (Provide the option to use libc++ even on all platforms) - #57375 (Add duration constants) - #57403 (Make extern ref HTTPS) Failed merges: - #57370 (Support passing cflags/cxxflags/ldflags to LLVM build) r? @ghost
Add constants
SECOND
,MILLISECOND
,MICROSECOND
, andNANOSECOND
tocore::time
.This will make working with durations more ergonomic. Compare: