3 ms·
To future proof an enum in rust you use the #[non_exhaustive] annotation. For C compatibility you have lots of options like #[repr(C)] or #[repr(i32)] to be C
by bluejekyll 6y ago
To future proof an enum in rust you use the #[non_exhaustive] annotation.
For C compatibility you have lots of options like #[repr(C)] or #[repr(i32)] to be C compatible. So not sure what you are referring to?
- brutt 6y agoThe problem is that #[repr(C)] enum is not compatible with C, even with #[non_exhaustive] annotation, and will never be, because C enum can be described in Rust terms as: #[repr(C)] enum Foo { A = 1, B = 2, C = 3, UNKNOWN(i32), } which is not possible to define in current version of Rust.