-
Notifications
You must be signed in to change notification settings - Fork 327
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
Implement Support For repr(int) non-C-like enums #78
Comments
Cool, this sounds really useful. The cbindgen work shouldn't be too difficult, just adding a new item and sharing some code with structs. |
Just so that we don't duplicate the work - I'm trying to implement this now. |
Relevant: rust-lang/rust#46123 |
Above PR was merged, so now |
I was stalled on refactoring generics in #85 (which affects tagged enums too), but happy to PR current state of things soon. |
It turns out
repr(u32, i8, etc...)
on non-C-like enums has had an unofficially specified and C(++)-compatible layout for a good while. I have filed an RFC to make it officially specified, but in the mean time we can set up cbindgen to generate this layout, which will let us use native Rust tagged unions in our bindings, and with today's stable Rust!You can check out the RFC for details (it's not quite the obvious layout), but here's a test Rust program to prove that it works:
works_for_me.rs
The text was updated successfully, but these errors were encountered: