-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking Issue for duration_constructors #120301
Comments
Thanks for adding this context. I was fairly certain that this would have been discussed before, but searching the issue tracker (for open issues) didn't turn up any existing discussion. I think it's okay to have this discussion here/now? From RFC 1040:
It goes on to quote JodaTime documentation; I'll quote the current version of this:
Note that the RFC is from 2015 and the latest discussion in #52556 is from 2018 so I feel like revisiting this decision isn't all that crazy. Personally I feel this distinction is well-established in the Rust ecosystem at this point, and there's a clear interplay between IMO each of these constructors have a clear unambiguous meaning in the context of a Note: I happen to be the current chrono maintainer, so I have some background in these things. |
We may want to consider as part of stabilization whether these could "just" (or in addition should be) associated constants. e.g., |
…Simulacrum core: add Duration constructors Add more `Duration` constructors. Tracking issue: rust-lang#120301. These match similar convenience constructors available on both `chrono::Duration` and `time::Duration`. What's the best ordering for these with respect to the existing constructors?
Rollup merge of rust-lang#120307 - djc:duration-constructors, r=Mark-Simulacrum core: add Duration constructors Add more `Duration` constructors. Tracking issue: rust-lang#120301. These match similar convenience constructors available on both `chrono::Duration` and `time::Duration`. What's the best ordering for these with respect to the existing constructors?
I'm happy to add them, but I'd be disappointed to remove the new constructors in favor of these. |
Just thought about this and found this issue :) I prefer the constructors to associated constants. Have you considered making the constructors take u32 instead of u64, so they don't need to worry about overflow and hence panicking? You lose the option of making a duration longer than (PS: I think the panic message in |
Yup. That looks like a classic case of copy-paste error. Also
is rather confusing.
|
@Mark-Simulacrum @djc I have attempted to add these associated constants in an idiomatic manner: #127700 I would love your feedback! |
I notice that it isn't currently proposed to add |
We also don't have It's notable that neither |
Feature gate:
#![feature(duration_constructors)]
This is a tracking issue for supporting larger unit sizes for
Duration
constructors.Public API
Add the following constructors to
Duration
:Duration::from_weeks()
Duration::from_days()
Duration::from_hours()
Duration::from_mins()
Steps / History
The text was updated successfully, but these errors were encountered: