Name the lifetime in the signature of SettableValue.set_on()
This change names the lifetime of Mut<'a, T> and requires that T outlives 'a. The motivation for this change came up while implementing `Map<K, ProtoStr>`. The Map implementation makes it so that `V` needs to implement the `MapWithKeyOps` trait which has an associated type with a lifetime (`Value<'a>`. The lifetime bound on `T` ensures that e.g. for `MapWithKeyOps<Value<'b>=&'b ProtoStr>` `'a` outlives `'b`.
PiperOrigin-RevId: 585657154
diff --git a/rust/optional.rs b/rust/optional.rs
index 3c49d7f..ba9955b 100644
--- a/rust/optional.rs
+++ b/rust/optional.rs
@@ -589,7 +589,10 @@
}
impl SettableValue<VtableProxied> for View<'_, VtableProxied> {
- fn set_on(self, _private: Private, mutator: Mut<VtableProxied>) {
+ fn set_on<'a>(self, _private: Private, mutator: Mut<'a, VtableProxied>)
+ where
+ VtableProxied: 'a,
+ {
SettableValue::<VtableProxied>::set_on(self.val(), Private, mutator)
}
@@ -603,7 +606,10 @@
}
impl SettableValue<VtableProxied> for i32 {
- fn set_on(self, _private: Private, mutator: Mut<VtableProxied>) {
+ fn set_on<'a>(self, _private: Private, mutator: Mut<'a, VtableProxied>)
+ where
+ VtableProxied: 'a,
+ {
(mutator.vtable.set)(mutator.msg, self)
}