Skip to content

Setting Customize::oneofs_non_exhaustive to false doesn't work #747

@5tan

Description

@5tan

I have tried:

fn main() {
    let customize = protobuf_codegen::Customize::default()
        .generate_accessors(true)
        .generate_getter(true)
        .oneofs_non_exhaustive(false); // <--- !!!

    protobuf_codegen::Codegen::new()
        .inputs(&vec!["my_message.proto"])
        .out_dir(".")
        .include(".")
        .customize(customize)
        .run()
        .expect("Running protoc failed.");
}

Example proto:

syntax = "proto3";

message MyMessage {
    string one = 1;
    oneof MyEnum {
        string two = 2;
        string three = 3;
    }
}

Result:

// (...)
/// Nested message and enums of message `MyMessage`
pub mod my_message {

    #[derive(Clone,PartialEq,Debug)]
    #[non_exhaustive]
    // @@protoc_insertion_point(oneof:MyMessage.MyEnum)
    pub enum MyEnum {
        // @@protoc_insertion_point(oneof_field:MyMessage.two)
        Two(::std::string::String),
        // @@protoc_insertion_point(oneof_field:MyMessage.three)
        Three(::std::string::String),
    }
// (...)

versions:

protobuf = "3.7.1"
protobuf-codegen = "3.7.1"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions