Skip to content

[feature request] serde(rename_all) for enums #25

@AndrejMitrovic

Description

@AndrejMitrovic

In Rust the serde macro can rename all enum members, for example:

#[serde(rename_all = "UPPERCASE")]
pub enum LoginType {
    Web = 0,
    Mobile = 1,
}

The D workaround for this is to use serdeKeys:

enum LoginType {
    @serdeKeys("WEB") Web,
    @serdeKeys("MOBILE") Mobile,
}

But would it be possible to add something similar in D that affects all the enum members? E.g.:

@serdeRenamed(Uppercase)
enum LoginType {
    Web,
    Mobile,
}

The exact syntax isn't that important to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions