Skip to main content

BottleEnum

Derive Macro BottleEnum 

Source
#[derive(BottleEnum)]
Expand description

Re-export of the procedural macro for deriving Display and FromStr for enums. Derives Display and FromStr for an enum to facilitate database mapping.

This macro generates implementations that allow the enum to be easily saved as a string (via to_string()) and loaded back from a string (via parse()). It uses the variant names as the string representation.

§Example

#[derive(BottleEnum, Debug, Clone, PartialEq)]
enum UserStatus {
    Active,
    Inactive,
    Pending,
}