Add duration constants#57375
Merged
Conversation
Contributor
|
(rust_highfive has picked a reviewer for you, use r? to override) |
Author
sugar700
approved these changes
Jan 6, 2019
Member
|
@bors r+ |
Collaborator
|
📌 Commit 72ec5aa has been approved by |
Contributor
|
Shouldn't we create a tracking issue for this first? |
Contributor
sugar700
suggested changes
Jan 6, 2019
src/libcore/time.rs
Outdated
| 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")] |
Contributor
There was a problem hiding this comment.
The issue number should be updated for the tracking issue in all places where the issue is mentioned.
Member
There was a problem hiding this comment.
Ah, good call. @stjepang, can you please update those to reference the tracking issue?
Member
|
@bors r- |
Member
|
Thanks! @bors r+ |
Collaborator
|
📌 Commit 8c902b6 has been approved by |
sugar700
approved these changes
Jan 7, 2019
emilyalbini
added a commit
to emilyalbini/rust
that referenced
this pull request
Jan 7, 2019
…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); ```
bors
added a commit
that referenced
this pull request
Jan 7, 2019
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add constants
SECOND,MILLISECOND,MICROSECOND, andNANOSECONDtocore::time.This will make working with durations more ergonomic. Compare: