Custom derive for automatically generating the accessor methods for Enums.
``` rust
extern crate enum_access;
enum A
fn itworks() {
let mut v: A
assert_eq!(v.get_name(), &"var1".to_string());
assert_eq!(v.get_index(), None);
assert_eq!(v.get_value(), None);
assert_eq!(v.iter_inputs(), vec![&9]);
assert_eq!(v.to_string(), "Variant1 name:9, input:0");
*v.get_mut_name() = "var1'".to_string();
assert_eq!(v.get_name(), &"var1'".to_string());
let mut v: A<u32> = A::Variant2 {
index: 0,
name: "var2".to_string(),
value: 23,
};
assert_eq!(v.get_name(), &"var2".to_string());
assert_eq!(v.get_index(), Some(&0));
assert_eq!(v.get_value(), Some(&23));
assert_eq!(v.iter_inputs(), Vec::<&i32>::new());
assert_eq!(v.to_string(), "");
*v.get_mut_index().unwrap() = 100;
assert_eq!(v.get_index(), Some(&100));
let mut v: A<u32> = A::Variant3 {
name: "var3".to_string(),
lhs: 1,
rhs: 2,
input: 3,
};
assert_eq!(v.get_name(), &"var3".to_string());
assert_eq!(v.get_index(), None);
assert_eq!(v.get_value(), Some(&1));
assert_eq!(v.iter_inputs(), vec![&1, &2]);
for n in v.iter_mut_inputs() {
*n += 10;
}
assert_eq!(v.iter_inputs(), vec![&11, &12]);
let v: A<u32> = A::Variant4(10u32, 11i32, 12i32, "var4".to_string());
assert_eq!(v.get_name(), &"var4".to_string());
assert_eq!(v.get_index(), Some(&10));
assert_eq!(v.get_value(), None);
assert_eq!(v.iter_inputs(), vec![&11, &12]);
assert_eq!(v.to_string(), "Variant4 index:10, name:var4");
} ```