pub trait EnumReflection {
// Required methods
fn get_fields(&self) -> Vec<&dyn Any>;
fn get_fields_mut(&mut self) -> Vec<&mut dyn Any>;
fn get_named_fields(&self) -> Vec<(&'static str, &dyn Any)>;
fn get_named_fields_mut(&mut self) -> Vec<(&'static str, &mut dyn Any)>;
}Expand description
§Enum reflection trait, automatically implemented by EnumReflect derive.
Dependency for enum_reflect
§Example Usage
fn print_any_enum_fields(target_enum: impl EnumReflection) {
for (field, value) in target_enum.get_named_fields() {
println!("Field {}", field);
}
}Function which gets any enum with #[derive(EnumReflect)] and prints it fields.