Remove PrimitiveMut::clear

PiperOrigin-RevId: 589296171
pull/15008/head
Alyssa Haroldsen 1 year ago committed by Copybara-Service
parent 74ff001424
commit f85b3477a3
  1. 6
      rust/primitive.rs
  2. 4
      rust/test/shared/accessors_proto3_test.rs

@ -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> {

@ -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));
}
@ -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));
}

Loading…
Cancel
Save