Named Constants
Procedural macro makes enums behave like named constants in languages like C/C++ or C#.
Put this attribute on an enum and it will be rewritten as a newtype struct. The enum variants are turned into associated constants.
Examples
use named_constants;
// Derives are applied to the newtype wrapper
// Required repr to specify the underlying type
let clubs = CLUBS;
let weird = CardSuit; // Legal!
Implementation notes
In the example above, CardSuit
is transformed into:
;
License
Licensed under MIT License, see license.txt.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions.