Skip to content

Serde like rename for Display & FromStr trait on enum #216

Closed
@ModProg

Description

@ModProg

i.e. I would expect

#[derive(Display)]
#[display(rename="snake_case")]
enum Test{
   First
}

println!("{}", Test::First) // -> prints "first"

The serde behaviour is documented here:
https://serde.rs/container-attrs.html#rename_all

#[serde(rename_all = "...")]

Rename all [...] variants [...] according to the given case convention. The possible values are "lowercase", "UPPERCASE", "PascalCase", "camelCase", "snake_case", "SCREAMING_SNAKE_CASE", "kebab-case", "SCREAMING-KEBAB-CASE".

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions