Description
At RustConf 2025 in Seattle, Tyler Mandry, co-lead of the Rust Language Team, sits down on behalf of the Rust Project Content Team with Alyssa Haroldsen, founder of explain.rs, for a design walkthrough of "open enums" as a possible Rust language feature.
A regular Rust enum is closed: constructing a value outside the listed variants is undefined behavior. An open enum, like a C++ enum class, can hold any integer value, which is exactly what you need when different versions of code exchange values across a binary interface. Topics include:
• Where the need shows up: protobuf version skew, syscall boundaries between kernel and user space in firmware, and forwarding wire messages you don't fully recognize
• Matching without exhaustiveness: "non-exhaustive for everyone, including myself," since even the defining crate can receive unknown values
• Three syntax alternatives, including a wildcard variant with a range discriminant (`_ = ..`), and extending explicit discriminants to patterns and ranges
• Casting integers into open enums with `as` when the discriminants span the whole repr type
• Dataful open enums and ABI evolution: why added variants can't have drop glue, and the ManuallyDrop plus `impl Drop` workaround
• How to do this on stable today: associated constants on a struct, bindgen's newtype enum mode, and Alyssa's open-enum attribute macro, plus the derive and IDE-integration drawbacks that make a real language feature attractive
Links mentioned:
explain.rs: https://explain.rs/
Alyssa on GitHub: https://github.com/kupiakos
The open-enum crate: https://github.com/kupiakos/open-enum
bindgen: https://github.com/rust-lang/rust-bindgen
The non_exhaustive attribute: https://doc.rust-lang.org/reference/attributes/type_system.html
Tyler Mandry: https://github.com/tmandry
Interview conducted by Tyler Mandry on behalf of the Rust Project Content Team.
