Skip to content

Commit

Permalink
Add test case for disabling #[non_exhaustive]
Browse files Browse the repository at this point in the history
  • Loading branch information
akonradi-signal authored and stepancheg committed Jun 17, 2024
1 parent 77e87d2 commit 764eb29
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use protobuf::OneofFull;
use protobuf_test_common::*;

use super::test_oneof_nonexhaustive_pb::*;

#[test]
fn test_oneof_nonexhaustive_disabled() {
use message_with_oneof_nonexhaustive_disabled::One;
match MessageWithOneofNonexhaustiveDisabled::default().one {
None => (),
Some(one) => match one {
One::FirstField(_) | One::SecondField(_) => (),
},
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = "proto2";

import "rustproto.proto";

package test_oneof;

message MessageWithOneofNonexhaustiveDisabled{
option (rustproto.oneofs_non_exhaustive) = false;

oneof one {
uint32 first_field = 1;
string second_field = 2;
}
}

0 comments on commit 764eb29

Please sign in to comment.