I usually like to combine Kinded with other traits. Examples are:
From<TraitEnumKind> for TraitEnum and Default for TraitEnumKind which is nice for enums containing implementors of a specific trait: let variant : TraitEnum = TraitEnumKind::default().into();
- another is
EnumMessage from strum to display additional information about the kinds.
While the Default impl is easy to do in the first case, manually implementing EnumMessage is a tad more annoying.
As a solution I would like to propose that variant attributes can also be passed on like so:
#[kinded(derive(Default, EnumMessage))]
pub enum UserId {
#[kinded(default)]
#[kinded(strum(message = "User by ID", detailed_message = "Identify a user by their (unique) id"))]
ById(u64),
#[kinded(strum(message = "User by Username", detailed_message = "Identify a user by their username"))]
ByName(String),
#[kinded(strum(message = "User by email", detailed_message = "Identify a user by their email address"))]
ByEmail(String),
}
This would also solve #18 like this:
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename="camelCase")]
#[kinded(serde(rename="camelCase"))]
pub enum Event {
#[serde(rename="LoggedIn"))]
#[kinded(serde(rename="LoggedIn"))]
Login(LoginDetail)
Logout(LogoutDetail)
}
which does contain redundancies but is still better than the current way.
I usually like to combine Kinded with other traits. Examples are:
From<TraitEnumKind> for TraitEnumandDefault for TraitEnumKindwhich is nice for enums containing implementors of a specific trait:let variant : TraitEnum = TraitEnumKind::default().into();EnumMessagefromstrumto display additional information about the kinds.While the
Defaultimpl is easy to do in the first case, manually implementingEnumMessageis a tad more annoying.As a solution I would like to propose that variant attributes can also be passed on like so:
This would also solve #18 like this:
which does contain redundancies but is still better than the current way.