Use the simpler set_x() instead of x_mut().set() in the Rust conformance test.

PiperOrigin-RevId: 613272179
pull/16081/head
Protobuf Team Bot 11 months ago committed by Copybara-Service
parent 009078df7a
commit 98511549b5
  1. 14
      conformance/conformance_rust.rs

@ -62,13 +62,13 @@ fn do_test(req: &ConformanceRequest) -> ConformanceResponse {
let message_type = req.message_type(); let message_type = req.message_type();
if req.requested_output_format() != WireFormat::Protobuf { if req.requested_output_format() != WireFormat::Protobuf {
resp.skipped_mut().set("only wire format output implemented"); resp.set_skipped("only wire format output implemented");
return resp; return resp;
} }
let bytes = match req.protobuf_payload_opt() { let bytes = match req.protobuf_payload_opt() {
Unset(_) => { Unset(_) => {
resp.skipped_mut().set("only wire format input implemented"); resp.set_skipped("only wire format input implemented");
return resp; return resp;
} }
Set(bytes) => bytes, Set(bytes) => bytes,
@ -78,7 +78,7 @@ fn do_test(req: &ConformanceRequest) -> ConformanceResponse {
b"protobuf_test_messages.proto2.TestAllTypesProto2" => { b"protobuf_test_messages.proto2.TestAllTypesProto2" => {
let mut proto = TestAllTypesProto2::new(); let mut proto = TestAllTypesProto2::new();
if let Err(_) = proto.deserialize(bytes) { if let Err(_) = proto.deserialize(bytes) {
resp.parse_error_mut().set("failed to parse bytes"); resp.set_parse_error("failed to parse bytes");
return resp; return resp;
} }
proto.serialize() proto.serialize()
@ -86,7 +86,7 @@ fn do_test(req: &ConformanceRequest) -> ConformanceResponse {
b"protobuf_test_messages.proto3.TestAllTypesProto3" => { b"protobuf_test_messages.proto3.TestAllTypesProto3" => {
let mut proto = TestAllTypesProto3::new(); let mut proto = TestAllTypesProto3::new();
if let Err(_) = proto.deserialize(bytes) { if let Err(_) = proto.deserialize(bytes) {
resp.parse_error_mut().set("failed to parse bytes"); resp.set_parse_error("failed to parse bytes");
return resp; return resp;
} }
proto.serialize() proto.serialize()
@ -94,7 +94,7 @@ fn do_test(req: &ConformanceRequest) -> ConformanceResponse {
b"protobuf_test_messages.editions.proto2.TestAllTypesProto2" => { b"protobuf_test_messages.editions.proto2.TestAllTypesProto2" => {
let mut proto = EditionsTestAllTypesProto2::new(); let mut proto = EditionsTestAllTypesProto2::new();
if let Err(_) = proto.deserialize(bytes) { if let Err(_) = proto.deserialize(bytes) {
resp.parse_error_mut().set("failed to parse bytes"); resp.set_parse_error("failed to parse bytes");
return resp; return resp;
} }
proto.serialize() proto.serialize()
@ -102,7 +102,7 @@ fn do_test(req: &ConformanceRequest) -> ConformanceResponse {
b"protobuf_test_messages.editions.proto3.TestAllTypesProto3" => { b"protobuf_test_messages.editions.proto3.TestAllTypesProto3" => {
let mut proto = EditionsTestAllTypesProto3::new(); let mut proto = EditionsTestAllTypesProto3::new();
if let Err(_) = proto.deserialize(bytes) { if let Err(_) = proto.deserialize(bytes) {
resp.parse_error_mut().set("failed to parse bytes"); resp.set_parse_error("failed to parse bytes");
return resp; return resp;
} }
proto.serialize() proto.serialize()
@ -110,7 +110,7 @@ fn do_test(req: &ConformanceRequest) -> ConformanceResponse {
_ => panic!("unexpected msg type {message_type}"), _ => panic!("unexpected msg type {message_type}"),
}; };
resp.protobuf_payload_mut().set(serialized); resp.set_protobuf_payload(serialized);
return resp; return resp;
} }

Loading…
Cancel
Save