From 7c5dd9ec6476a63b5127e49e1c47135affe45ed3 Mon Sep 17 00:00:00 2001
From: Protobuf Team Bot <protobuf-github-bot@google.com>
Date: Wed, 17 Jul 2024 23:06:29 -0700
Subject: [PATCH] Remove the second 'unset' generic argument from Optional

This is no longer needed with our new design.

PiperOrigin-RevId: 653488903
---
 rust/optional.rs                   | 8 +++-----
 rust/test/shared/accessors_test.rs | 6 ++----
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/rust/optional.rs b/rust/optional.rs
index 1f5cb9ad46..221f4d9ed2 100644
--- a/rust/optional.rs
+++ b/rust/optional.rs
@@ -23,14 +23,14 @@ use std::ptr;
 ///
 /// Two `Optional`s are equal if they match both presence and the field values.
 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub enum Optional<SetVal, UnsetVal = SetVal> {
+pub enum Optional<T> {
     /// The field is set; it is present in the serialized message.
     ///
     /// - For an `_opt()` accessor, this contains a `View<impl Proxied>`.
     /// - For a `_mut()` accessor, this contains a [`PresentField`] that can be
     ///   used to access the current value, convert to [`Mut`], clear presence,
     ///   or set a new value.
-    Set(SetVal),
+    Set(T),
 
     /// The field is unset; it is absent in the serialized message.
     ///
@@ -38,7 +38,7 @@ pub enum Optional<SetVal, UnsetVal = SetVal> {
     ///   the default value.
     /// - For a `_mut()` accessor, this contains an [`AbsentField`] that can be
     ///   used to access the default or set a new value.
-    Unset(UnsetVal),
+    Unset(T),
 }
 
 impl<T> Optional<T> {
@@ -53,9 +53,7 @@ impl<T> Optional<T> {
     pub fn new(val: T, is_set: bool) -> Self {
         if is_set { Optional::Set(val) } else { Optional::Unset(val) }
     }
-}
 
-impl<T, A> Optional<T, A> {
     /// Converts into an `Option` of the set value, ignoring any unset value.
     pub fn into_option(self) -> Option<T> {
         if let Optional::Set(x) = self { Some(x) } else { None }
diff --git a/rust/test/shared/accessors_test.rs b/rust/test/shared/accessors_test.rs
index f108c889c1..c0365b1d9e 100644
--- a/rust/test/shared/accessors_test.rs
+++ b/rust/test/shared/accessors_test.rs
@@ -609,10 +609,8 @@ fn test_singular_msg_field() {
 #[test]
 fn test_message_opt() {
     let msg = TestAllTypes::new();
-    let opt: Optional<
-        unittest_rust_proto::test_all_types::NestedMessageView<'_>,
-        unittest_rust_proto::test_all_types::NestedMessageView<'_>,
-    > = msg.optional_nested_message_opt();
+    let opt: Optional<unittest_rust_proto::test_all_types::NestedMessageView<'_>> =
+        msg.optional_nested_message_opt();
     assert_that!(opt.is_set(), eq(false));
     assert_that!(opt.into_inner().bb(), eq(0));
 }