Skip to content

Strip prefixes from enum variants in generated code #1379

@jacob-curley-fnal

Description

@jacob-curley-fnal

Per the Protobuf style guide on enums, enumerated values should be of the form

enum MyEnum {
    MY_ENUM_UNKNOWN = 0;   // Or MY_ENUM_UNSPECIFIED
    MY_ENUM_<Some value 1> = 1;
    MY_ENUM_<Some value 2> = 2;
    ...
    MY_ENUM_<Some value N> = N;
}

The Rust style guide on enums, by contrast, discourages using a repeated prefix in enums.

Would it be possible for the code generator to handle this automatically? I'd like to be able to have conformant .proto files and .rs files, without configuring the #[allow(clippy::enum_variant_names)] in the build.rs file of every project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions