rust-protobuf icon indicating copy to clipboard operation
rust-protobuf copied to clipboard

Setting Customize::oneofs_non_exhaustive to false doesn't work

Open 5tan opened this issue 11 months ago • 1 comments

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"

5tan avatar Nov 07 '24 09:11 5tan