cbindgen
cbindgen copied to clipboard
Export helper casts but not helper construction methods.
There are a few settings in cbindgen that generate helper C++ methods for working with tagged enums, but they all seem tied to derive helper methods:
- derive_helper_methods: false
- derive_const_casts: true
- derive_mut_casts: false
With this configuration, no helper cast methods are generated. For my use case, the user should not create these things themselves, instead, they should use my provided APIs. All I want are the casts so the user can "pattern match" over them in an easy way, but there does not appear to be an option to do so.
Yeah, I think that the history of the code went something like on the the first iteration, derive_helper_methods
, generated both IsFoo()
and static Foo()
methods.
Then the casts were added, but there was never an option to decouple the constructor functions from the cast functions.
I think adding an option (default true) that generates the constructors when derive_helper_methods
is true would be the best solution. That way you can opt out of it.