Mark owned Repeated & Map types as Send & Sync.
PiperOrigin-RevId: 640063798
diff --git a/rust/repeated.rs b/rust/repeated.rs
index 679e279..280eeff 100644
--- a/rust/repeated.rs
+++ b/rust/repeated.rs
@@ -341,6 +341,13 @@
_phantom: PhantomData<T>,
}
+// SAFETY: `Repeated` is Sync because it does not implement interior mutability.
+unsafe impl<T: ?Sized + ProxiedInRepeated> Sync for Repeated<T> {}
+
+// SAFETY: `Repeated` is Send because it's not bound to a specific thread e.g.
+// it does not use thread-local data or similar.
+unsafe impl<T: ?Sized + ProxiedInRepeated> Send for Repeated<T> {}
+
impl<T: ?Sized + ProxiedInRepeated> Repeated<T> {
pub fn new() -> Self {
T::repeated_new(Private)
@@ -368,9 +375,6 @@
}
}
-// SAFETY: `Repeated` does not allow for shared mutability.
-unsafe impl<T: ProxiedInRepeated> Sync for Repeated<T> {}
-
impl<T> Proxied for Repeated<T>
where
T: ProxiedInRepeated + ?Sized,