enum-field-getter
A simple derive macro used to implement methods to access fields which are of the same type across every tuple/struct enum variant.
Usage
Derive EnumFieldGetter. For tuple enum variants, produces get_n(&self) -> Option<&_> and get_n_mut(&mut self) -> Option<&mut _> methods for each tuple member (starting from 0); for struct variants, getters are of the form prop(&self) -> Option<&_> and prop_mut(&mut self) -> Option<&mut _>. Getters are only produced so long as that member is the same type across all enum variants - if they are of different types, no getter will be produced for that member. These methods are produced even if that member doesn't exist for all enum variants - in the case that it doesn't exist, the getter will return None.
Examples
use EnumFieldGetter;
let foo = Bar;
let foo0 = foo.get_0;
assert_eq!;
let foo1 = foo.get_1;
assert!;
use EnumFieldGetter;
let mut boop = Baa ;
let boop_a = boop.a;
assert_eq!;
let boop_c = boop.c;
assert_eq!;
*boop.b_mut.unwrap = 43;
assert_eq!;