Convert number to enum
This crate provides a derive macro to generate a function for converting a primitive integer into the corresponding variant of an enum.
The generated function is named
n and has the following signature:
Repr is an integer type of the right size as described in more
The generated signature depends on whether the enum has a
attribute. If a
repr is specified, the input to
n will be required to be
of that type.
// expands to:
On the other hand if no
repr is specified then we get a signature that is
generic over a variety of possible types.
The conversion respects explictly specified enum discriminants. Consider this enum:
Letter::n(65) would return