diff --git a/rust/primitive.rs b/rust/primitive.rs index 6d0e23538184..0b81d2e2e98e 100644 --- a/rust/primitive.rs +++ b/rust/primitive.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> { diff --git a/rust/test/shared/accessors_proto3_test.rs b/rust/test/shared/accessors_proto3_test.rs index 945af2aed5a5..4b7daa425e31 100644 --- a/rust/test/shared/accessors_proto3_test.rs +++ b/rust/test/shared/accessors_proto3_test.rs @@ -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)); }