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

Can enum::count() be a const function? #58

Closed
ArekPiekarz opened this issue Jun 30, 2019 · 2 comments
Closed

Can enum::count() be a const function? #58

ArekPiekarz opened this issue Jun 30, 2019 · 2 comments

Comments

@ArekPiekarz
Copy link

When EnumCount was introduced, there was a comment that the count() function could be const once the required feature get stabilized in Rust. It seems to me it is possible now, but I'm not a Rust expert yet, so I could be wrong. What is your opinion of this?

As a side effect, this could get rid of the X _COUNT constants polluting the public namespace, but I don't know if you'd want to remove them due to backwards compatibility. However, according to semver, version 0.x.y does not provide any guarantees, so the users should not have any assumptions anyway.

@xoac
Copy link

xoac commented Jul 1, 2019

I think in Rust 1.35 is still impossible

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f57dce05c0bf5b244fb2f370ac810072

rustc --explain E0379 say

Trait methods cannot be declared const by design. For more information, see
RFC 911.

@ArekPiekarz
Copy link
Author

Thanks, I hope it gets implemented one day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants