-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add CTFE function for enum types to return the number of variants. #8803
Comments
This isn't going to happen because we aren't going to add special-cased CTFE functions. Rust doesn't have CTFE beyond syntax extensions. The number of |
I don't feel super strongly about this, but it has come up at least twice already in Servo. One case was in the profiler where we have a enum for the categories and want to define an array of the size of the number of categories. I think a similar case occurs in rust-mozjs where there are a bunch of object types and we must make sure to get the number of reserved slots right or else things will crash. How does retrieving the variants at runtime work? |
You can implement the You can look at what Although, we could also add intrinsics for this if there's a wide need for it. |
Fix `cmp_owned` on copy types fixes rust-lang#8803 fixes rust-lang#7365 changelog: Don't lint `cmp_owned` on `From::from` for copy types
This would allow for something like this:
The text was updated successfully, but these errors were encountered: