-
-
Notifications
You must be signed in to change notification settings - Fork 111
Represent enums as constants instead of enums #480
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
Comments
@sdroege You don't understand, how it solves problem with function accepts enum values? Now it accept any int? |
Basically what has to be done to make this safe is that the sys bindings use integers and constants. And the non-sys bindings use enums with the The important part is that we should never have an out of range value anywhere, currently we can at the sys layer. We should try to fix that before the next release. We already have the constants in the sys bindings, just the enums would go away. |
If it only for sys, then IMHO this good, while slightly loss in declarability it removes UB |
OK, I'll prepare a PR :) |
The C code might be extended by additional values without the bindings being updated, which then is considered undefined behaviour on the Rust side. As such we must use plain integers here. The enums stay as enums in the non-sys crates and the conversion traits ensure that the conversion from the integers to the actual enum values is done correctly, while storing unknown values in a hidden enum variant. Fixes gtk-rs#480
As pangocairo don't contains enums, seems gtk last PR. |
Uh oh!
There was an error while loading. Please reload this page.
From the bindgen 0.31.0 release notes
The text was updated successfully, but these errors were encountered: