twilight
twilight copied to clipboard
Transform enum struct variants into separate structs for backwards compatibility
pub enum Foo {
Bar {
a: String,
b: i32,
}
}
becomes
#[non_exhaustive]
pub enum Foo {
Bar(Bar),
}
#[non_exhaustive]
pub struct Bar {
pub a: String,
pub b: i32,
}
I'd just like to note that this too is valid rust:
#[non_exhaustive]
pub enum Foo {
#[non_exhaustive]
Bar { a: String, b: i32 },
}
There's no need to split them into separate types just for the #[non_exhaustive] attribute, see https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute