Macro feattle::feattle_enum [−][src]
Define an enum
that can be used as a type for a feattle
The generated enum
will have these standard traits: Debug
, Clone
, Copy
, Eq
,
PartialEq
, PartialOrd
, Ord
, FromStr
, Display
. And mainly, it will implement
crate::FeattleStringValue
so that it can be used a feattle type.
Only enum
s whose variants do not carry any extra information are supported.
Examples
In the simplest form:
use feattle_core::feattle_enum; feattle_enum! { enum Colors { Red, Green, Blue } }
However, it also works with other visibility keywords and additional attributes on the enum
itself or its variants. Those attributes will not be modified by this lib, allowing composition
with other libs. For example, you can also make the enum Serialize
:
use feattle_core::feattle_enum; use serde::Serialize; feattle_enum! { #[derive(Serialize)] pub(crate) enum Colors { #[serde(rename = "R")] Red, #[serde(rename = "G")] Green, #[serde(rename = "B")] Blue, } }