-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Casting an enum to an int inside match #3580
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I believe this is a simple type mismatch and if you write |
My previous comment is obviously wrong since |
Before you ask, if I try to cast the int as an enum directly I get this:
That was the whole reason why I was doing the massive match – it actually comes up a few times in my code. |
See #2132 |
I would go so far as to say that this is a dup of #2132. |
Incidentally, it also suggests an easy workaround. You can use reinterpret_cast, perhaps with some comparisons to make sure the value is in the proper range. |
…RalfJung Implement non-null pointer for malloc(0) Use non-null pointer for malloc(0) as mentioned in rust-lang#3576 to detect leaks and double free of ``malloc(0)`` addresses.
I'm trying to convert an
int
to anenum
, so I was attempting to use a match. Unfortunately I can't cast the enum values.Error:
This is the ugly work-around I've been using:
The text was updated successfully, but these errors were encountered: