From 06444cb6a187ff209b70222afacd3a42398df2df Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Mon, 18 Mar 2024 14:22:00 -0700 Subject: [PATCH] Clean up some now-unnecessary or_default()s PiperOrigin-RevId: 616946153 --- rust/proxied.rs | 2 +- rust/test/shared/accessors_proto3_test.rs | 2 +- rust/test/shared/accessors_test.rs | 10 +++++----- rust/test/shared/simple_nested_test.rs | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/rust/proxied.rs b/rust/proxied.rs index 58794796f8..8d9214d28e 100644 --- a/rust/proxied.rs +++ b/rust/proxied.rs @@ -170,7 +170,7 @@ pub trait MutProxy<'msg>: ViewProxy<'msg> { /// example: /// /// ```ignore - /// let mut sub: Mut = msg.submsg_mut().or_default(); + /// let mut sub: Mut = msg.submsg_mut(); /// sub.as_mut().field_x_mut().set(10); // field_x_mut is fn(self) /// sub.field_y_mut().set(20); // `sub` is now consumed /// ``` diff --git a/rust/test/shared/accessors_proto3_test.rs b/rust/test/shared/accessors_proto3_test.rs index f9af74a453..0b900280d0 100644 --- a/rust/test/shared/accessors_proto3_test.rs +++ b/rust/test/shared/accessors_proto3_test.rs @@ -183,7 +183,7 @@ fn test_oneof_accessors() { assert_that!(msg.oneof_uint32_opt(), eq(Optional::Unset(0))); assert_that!(msg.oneof_field(), matches_pattern!(not_set(_))); - msg.oneof_nested_message_mut().or_default(); // Cause the nested_message field to become set. + msg.oneof_nested_message_mut(); // Cause the nested_message field to become set. assert_that!(msg.oneof_bytes_opt(), matches_pattern!(Optional::Unset(_))); assert_that!(msg.oneof_field(), matches_pattern!(OneofNestedMessage(_))); diff --git a/rust/test/shared/accessors_test.rs b/rust/test/shared/accessors_test.rs index ad9068103d..70694aecb2 100644 --- a/rust/test/shared/accessors_test.rs +++ b/rust/test/shared/accessors_test.rs @@ -492,7 +492,7 @@ fn test_singular_msg_field() { // testing reading an int inside a view assert_that!(msg_view.bb(), eq(0)); - let mut nested_msg_mut: NestedMessageMut = msg.optional_nested_message_mut().or_default(); + let mut nested_msg_mut: NestedMessageMut = msg.optional_nested_message_mut(); // test reading an int inside a mut assert_that!(nested_msg_mut.bb(), eq(0)); @@ -543,12 +543,12 @@ fn test_setting_submsg() { } #[test] -fn test_msg_or_default() { +fn test_msg_mut_initializes() { let mut msg = TestAllTypes::new(); assert_that!(msg.optional_nested_message_opt().is_set(), eq(false)); - let _ = msg.optional_nested_message_mut().or_default(); - // confirm that that or_default makes the field Present + let _ = msg.optional_nested_message_mut(); + // confirm that that optional_nested_message_mut makes the field Present assert_that!(msg.optional_nested_message_opt().is_set(), eq(true)); msg.clear_optional_nested_message(); @@ -757,7 +757,7 @@ fn test_group() { assert_that!(m.optionalgroup_opt().is_set(), eq(false)); assert_that!(m.optionalgroup().a(), eq(0)); - m.optionalgroup_mut().or_default().set_a(7); + m.optionalgroup_mut().set_a(7); assert_that!(m.optionalgroup_opt().is_set(), eq(true)); assert_that!(m.optionalgroup().a(), eq(7)); } diff --git a/rust/test/shared/simple_nested_test.rs b/rust/test/shared/simple_nested_test.rs index cebd982b7f..a6c67cf4ea 100644 --- a/rust/test/shared/simple_nested_test.rs +++ b/rust/test/shared/simple_nested_test.rs @@ -103,10 +103,10 @@ fn test_recursive_view() { #[test] fn test_recursive_mut() { let mut rec = nested_proto::Recursive::new(); - let mut one = rec.rec_mut().or_default(); - let mut two = one.rec_mut().or_default(); - let mut three = two.rec_mut().or_default(); - let mut four = three.rec_mut().or_default(); + let mut one = rec.rec_mut(); + let mut two = one.rec_mut(); + let mut three = two.rec_mut(); + let mut four = three.rec_mut(); four.set_num(1); assert_that!(four.num(), eq(1));