define_cases

Macro define_cases 

Source
macro_rules! define_cases {
    {
    $(
        $heck:ident $( $keyword:literal )* $in_paste:ident,
    )*
} => { ... };
}
Expand description

Define cases using heck

heck doesn’t provide standard names for case conversions, or an enum to represent a case conversion. This macro defines both. Specifically:

  • The fieldless enum ChangeCase.
  • Its FromStr implementation, which accepts the $keywords.
  • Its apply() method, which actually performs the conversion.

$heck is the name of the As conversion struct in the heck API. It will become the variant name in ChangeCase.

$keyword are the keywords we recognise for this case conversion.