enum-stringify
Set of macros (only one for now) to generate a string representation of an enum. When using
#[derive(EnumStringify)]
on an enum, it will implement std::fmt::Display
, TryFrom<&str>
,
TryFrom<String>
and std::str::FromStr
for it. It will use the name of the enum variant as the
string representation.
Usage
use EnumStringify;
Custom string representation
You can customize the string representation of the enum by adding prefixes or/and suffixes to the variants and also changing the case of the string representation.
use EnumStringify;
In this case the string representation of MyEnum::Variant1
will be MyPrefixVariant1MySuffix
(and
so on for the other variants).
Documentation and installation
See docs.rs for documentation. It is available on crates.io as well.