-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Make Duration constructors and accessors const fns #33033
Conversation
Thanks! r=me |
@bors: r=GuillaumeGomez |
📌 Commit 379c40f has been approved by |
@bors: r- @GuillaumeGomez this is a change which has ramifications on the stability of these APIs and how we might change them in the future, I'd like to discuss this at a libs triage meeting before we move forward with this just yet. We currently don't have many conventions for what is or what isn't a |
@alexcrichton: My bad, I didn't think that the change would be that big. I'll wait for your come back on this. |
@luqmana to be clear, @GuillaumeGomez doesn't quite have r+ rights yet. I've been working with him on smaller things, but I'm supposed to approve them before they get put in. (and even that is docs only, not code). He forgot to CC me on this one. I'm surprised Bors allowed this, actually. |
@steveklabnik Ah whoops, my mistake. Actually, I don't think bors cares what comes after r= as long as the person actually writing the comment is allowed to. |
@@ -81,7 +83,7 @@ impl Duration { | |||
/// nanoseconds are not represented in the returned value). | |||
#[stable(feature = "duration", since = "1.3.0")] | |||
#[inline] | |||
pub fn as_secs(&self) -> u64 { self.secs } | |||
pub const fn as_secs(&self) -> u64 { self.secs } |
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.
These kind of const fns only work in statics, they don't work in array lengths and other true constants (yet). Is there a use case for this? If not, I suggest to delay this until we have a unified MIR-powered const evaluator
The libs team discussed this PR during triage today and the decision was to close for now. Adding a |
Closes #33029
r? @alexcrichton