Now, we assume here that the last definition STATE_NAME_TOTAL is the correct number of definitions before it, because in C the value of the definitions start at 0 and grow each new definition, if no explicit assignment is made.
The problem here is that StateName::Total will also need to be taken in account in every match expression. I think it would be interesting to have some sort of expression to get the number of variants in an C-style enum in Rust.
But array length needs to be a (guaranteed) compile-time constant. So maybe what we need here is a const fn-ification of enum_derive or some similar crate. I can't think of any reason why it wouldn't be straightforward to const-ify things like iter_variants().
I know I've seen a macro to generate just an associated const VARIANTS: [Self; N] before. I've definitely used a manual version of it to implement TryFrom<reprN> before.
That said, if you really want an enum associative array, EnumMap is probably the way to go.