-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Make cast generated enums to i32 non-scalar #251
Conversation
Its second part of |
AppVeyor build succeeded, @gkoz, please, merge this |
Seems I missread matches, need more |
Or not? |
I tried micro-optimisation on match. |
This got me thinking: if we somehow get an unexpected variant from the library, should it be possible to pass it back unchanged? This would require complicated workarounds and making enums much fatter. |
We can add flag for some enums, that convert it to |
These enums still defended against direct converting, so I don't see any problems. |
Problem is we can't allow putting arbitrary |
Sorry, don't understand :( |
Enum members can't have private fields. pub struct Discriminant<T> {
value: i32,
_dummy: PhantomData<*const T>,
};
impl<T> struct Discriminant<T> {
// there shouldn't be a safe way to put arbitrary discriminants into enums
pub unsafe fn new(value: i32) -> Self {
Discriminant {
value: value,
_dummy: PhantomData::new(),
}
}
}
pub enum Foo {
Member1,
Member2,
Member3,
__Nonexhaustive(Discriminant<Self>),
} This looks like it's not worth the trouble at this point. |
IMHO it not much related to this PR ;) |
No description provided.