This could be done with a custom newtype (to implement enum-using indexing) backed by a struct of the right size and a custom Derive.
Alowing to write code along these lines:
/// Some possible name for the crate.
use ::enum_index::EnumIndex;
#[derive(EnumIndex)]
// this will declare the struct FooIndex<T : Sized> { A: T, B: T, C: T }
// and impl<T : Sized> ::std::ops::Index{,Mut}<Foo> for FooIndex<T>
enum Foo {
A,
B,
C,
}
static LOOKUP: FooIndex<i32> = {
A: 42,
B: 69,
C: 0,
};
fn main ()
{
assert_eq!(LOOKUP.A, 1); // static indexing
assert_eq!(LOOKUP[Foo::A], 1); // dynamic but unfallible indexing
}