Skip to content

Commit

Permalink
Remove PrimitiveMut::clear
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 589296171
  • Loading branch information
kupiakos authored and copybara-github committed Dec 9, 2023
1 parent 74ff001 commit f85b347
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
6 changes: 0 additions & 6 deletions rust/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ macro_rules! impl_singular_primitives {
pub fn set(&mut self, val: impl SettableValue<$t>) {
val.set_on(Private, self.as_mut());
}

pub fn clear(&mut self) {
// The default value for a boolean field is false and 0 for numerical types. It
// matches the Rust default values for corresponding types. Let's use this fact.
SettableValue::<$t>::set_on(<$t>::default(), Private, MutProxy::as_mut(self));
}
}

impl<'a> ViewProxy<'a> for PrimitiveMut<'a, $t> {
Expand Down
4 changes: 2 additions & 2 deletions rust/test/shared/accessors_proto3_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn test_fixed32_accessors() {
assert_that!(msg.optional_fixed32_mut().get(), eq(42));
assert_that!(msg.optional_fixed32(), eq(42));

msg.optional_fixed32_mut().clear();
msg.optional_fixed32_mut().set(u32::default());
assert_that!(msg.optional_fixed32(), eq(0));
assert_that!(msg.optional_fixed32_mut().get(), eq(0));
}
Expand All @@ -38,7 +38,7 @@ fn test_bool_accessors() {
assert_that!(msg.optional_bool(), eq(true));
assert_that!(msg.optional_bool_mut().get(), eq(true));

msg.optional_bool_mut().clear();
msg.optional_bool_mut().set(bool::default());
assert_that!(msg.optional_bool(), eq(false));
assert_that!(msg.optional_bool_mut().get(), eq(false));
}
Expand Down

0 comments on commit f85b347

Please sign in to comment.