-
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 RangeEnum
trait
#10418
Comments
One thought I had in an e-mail conversation with @martindemello was that it might be useful to make a trait for working with enums which allows conversion not from the discriminant of an enum but rather from its index in the list of variants (which is usually, but not always, equal to the discriminant). This would allow us to guarantee for example that we can compact use bits from |
Java defines the |
I'd rather say the onus is on the caller of |
I think Ordinal would be a better trait name than RangeEnum |
On Fri, Nov 15, 2013 at 10:34:02PM -0800, Martin DeMello wrote:
+1 |
This is still relevant and useful. Should this be baked into the compiler somehow? |
I'm pulling a massive triage effort to get us ready for 1.0. As part of this, I'm moving stuff that's wishlist-like to the RFCs repo, as that's where major new things should get discussed/prioritized. This issue has been moved to the RFCs repo: rust-lang/rfcs#824 |
Run dogfood to completion Run dogfood on all packages before failing the test. Failing early is painful on lints which trigger on multiple crates. changelog: None
Following the last few comments on #4926.
Add a
RangeEnum
trait for simple Enums (which implementFromPrimitive
) to allow quick access to the total number of values, and provide an iterator over the values.The text was updated successfully, but these errors were encountered: