Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
5tan opened this issue Nov 7, 2024 · 0 comments
Open

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

5tan opened this issue Nov 7, 2024 · 0 comments

Comments

@5tan
Copy link

5tan commented Nov 7, 2024

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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant