Add Duration::MAX associated constant#72436
Add Duration::MAX associated constant#72436marmeladema wants to merge 2 commits intorust-lang:masterfrom
Duration::MAX associated constant#72436Conversation
|
(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.
| #[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.
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::MAXas associated constant on the same model asu64::MAXetc.I re-used
const_checked_int_methodsfeature gate to constifyDuration::new, it might not be the best approach but i thought this PR would help start the discussion.