-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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::MAX
associated constant
#72436
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
pub fn new(secs: u64, nanos: u32) -> Duration { | ||
let secs = | ||
secs.checked_add((nanos / NANOS_PER_SEC) as u64).expect("overflow in Duration::new"); | ||
#[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")] |
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.
#[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")] | |
#[rustc_const_unstable(feature = "const_duration_new", issue = "53718")] |
I don't think we should reuse const_checked_int_methods
here.
You might have to add #![feature(const_duration_new)]
to src/libcore/lib.rs so Duration::MAX
can use this.
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.
Also there should be a new tracking issue then.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
r? @RalfJung |
Not sure I can just approve new APIs like that.^^ Also, there is some overlap with #72481. Cc @rust-lang/wg-const-eval |
Let's close this in favor of #72481 even if it does not introduce |
(To merge after #72434)
This change introduce
Duration::MAX
as associated constant on the same model asu64::MAX
etc.I re-used
const_checked_int_methods
feature gate to constifyDuration::new
, it might not be the best approach but i thought this PR would help start the discussion.