frozenlib / parse-display

Procedural macro to implement Display and FromStr using common settings.
Apache License 2.0
182 stars 14 forks source link

style="lowercase" removes snake casing #30

Closed bayarmunkh closed 1 year ago

bayarmunkh commented 1 year ago

Hello!

This is more of a question whether the following is expected behavior or not. When using lowercase style, it remove all the underscores from that variant. As a workaround, declaring overrides on those affected variants is needed. See the example below.

#[display(style = "lowercase")]
pub enum MyEnum {
    #[display("var_a")] // without this override, it converts to `vara` by removing the underscore by default
    Var_A,
    VarB,
}
frozenlib commented 1 year ago

Hi.

This is the intended behavior.

However, it might be misinterpreted as a conversion by str::to_lowercase, so if a better name than lowercase is found, we might consider changing the style name in the future.

Also, it might be a good idea to add to_lowercase style that performs the conversion by str::to_lowercase.