-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
enum entries are not compile-time constants #31300
Comments
@Kingsquee: Quick triage: this looks to be an issue in how the compiler generates and assigns the discriminant (0, 1, 2, etc.) for each field. If you specify these yourself (see below) it will compile just fine. pub enum Foo {
A = 0,
B = 1,
CAPACITY = 2,
}
fn main() {
let arr = [0; Foo::CAPACITY as usize];
} |
@dirk Thanks, good to know! |
@Kingsquee: Glad to help. 😄 In regards to the original issue: is predictable auto-assignment of descriminants for enums a feature that should be introduced into the language? @steveklabnik: Would there be a better place to start/revive this discussion than in this issue? |
This issue is tracked here #23898 (this is iow a duplicate) |
@mitaa Thanks, I'll close this issue then. |
The text was updated successfully, but these errors were encountered: