physx-rs
physx-rs copied to clipboard
Generate type-safe Rust enums from PhysX enums
The code generator for physx-sys
currently generates this peculiar construct for C++ enums:
pub mod PxMeshMidPhase{
pub type Enum = u32;
pub const eBVH33: Enum = 0u64 as u32;
pub const eBVH34: Enum = 1u64 as u32;
pub const eLAST: Enum = 2u64 as u32;
}
This is to match the C++ closely in terms of usage, and allow binary ops on flags.
While workable, the solution doesn't provide type safety, and makes it unwieldy to match
on. We should investigate using more proper Rust enums an type-safe flags.
@h3r2tic I looked through my browser history and I think it was this crate I was referring to earlier: https://docs.rs/enumflags2/0.5.1/enumflags2/.
Oops, this was fixed in #183