Custom derive for automatically generating the accessor methods for Enums.
``` rust
extern crate enum_access;
enum Enum
fn itworks() {
let mut v: Enum
assert_eq!(v.name(), &"var1".to_string());
assert_eq!(v.index(), None);
assert_eq!(v.value(), None);
assert_eq!(v.inputs(), vec![&9]);
assert_eq!(v.to_string(), "Variant1 name:9, input:0");
*v.name_mut() = "var1'".to_string();
assert_eq!(v.name(), &"var1'".to_string());
let mut v: Enum<u32> = Enum::Variant2 {
index: 0,
name: "var2".to_string(),
value: 23,
};
let variant2: EnumVariant2Inner = v.clone().into();
assert_eq!(v, Enum::from(variant2));
assert_eq!(v.name(), &"var2".to_string());
assert_eq!(v.index(), Some(&0));
assert_eq!(v.value(), Some(&23));
assert_eq!(v.inputs(), Vec::<&i32>::new());
assert_eq!(v.to_string(), "");
*v.index_mut().unwrap() = 100;
assert_eq!(v.index(), Some(&100));
let mut v: Enum<u32> = Enum::Variant3 {
name: "var3".to_string(),
lhs: 1,
rhs: 2,
input: 3,
};
let variant3: EnumVariant3Inner = v.clone().into();
assert_eq!(v, Enum::from(variant3));
assert_eq!(v.name(), &"var3".to_string());
assert_eq!(v.index(), None);
assert_eq!(v.value(), Some(&1));
assert_eq!(v.inputs(), vec![&1, &2]);
for n in v.inputs_mut() {
*n += 10;
}
assert_eq!(v.inputs(), vec![&11, &12]);
let v: Enum<u32> = Enum::Variant4(10u32, 11i32, 12i32, "var4".to_string());
assert_eq!(v.name(), &"var4".to_string());
assert_eq!(v.index(), Some(&10));
assert_eq!(v.value(), None);
assert_eq!(v.inputs(), vec![&11, &12]);
assert_eq!(v.to_string(), "Variant4 index:10, name:var4");
} ```