Skip to content
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 constructor functions const. #33029

Closed
quadrupleslap opened this issue Apr 16, 2016 · 5 comments
Closed

Make duration constructor functions const. #33029

quadrupleslap opened this issue Apr 16, 2016 · 5 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@quadrupleslap
Copy link

Is there anything stopping the functions from_millis, from_secs and new in std::time::Duration from being constant?

@nagisa
Copy link
Member

nagisa commented Apr 16, 2016

You cannot use a const fn with stable compiler as a constant function, so for most purposes making these functions const now is not really useful.

@sfackler
Copy link
Member

I'm not totally sure I understand that, @nagisa - stable users of the compiler will see no change and people on nightlies will be able to take advantage of the const-ness.

@tbu-
Copy link
Contributor

tbu- commented May 13, 2016

Now impossible until we allow panics in const functions: #33072.

@ticki
Copy link
Contributor

ticki commented Jul 19, 2016

#34918

@steveklabnik steveklabnik added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed A-libs labels Mar 24, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 25, 2017
@dtolnay
Copy link
Member

dtolnay commented Nov 18, 2017

This is going to depend on what happens with rust-lang/rfcs#1383. Let's continue to track this as part of #24111 as Alex commented in #33033 (comment):

Adding a const fn is a serious API commitment that we may not always be able to uphold (e.g. #33072). In the meantime const fn is still unstable, and when stabilized we will likely want to perform a pass over the standard library to audit for functions which are const-compatible at that time.

@dtolnay dtolnay closed this as completed Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

9 participants