ordinalizer 0.1.0

Derive an ordinal function for enums which returns the index of a variant in the enum definition.

A simple derive macro to generate an ordinal() method for enums.

Unlike num_derive::ToPrimitive, this derive macro allows non-C-like enums. The ordinal function reflects the variant of the enum and does not account for fields.


use ordinalizer::Ordinal;
enum Animal {
Cat {
age: i32,

assert_eq!(Animal::Dog.ordinal(), 0);
assert_eq!((Animal::Cat { age: 10 }).ordinal(), 1);