Implement Send and Sync unconditionally for exposed Id type. (#3801)

This commit is contained in:
kyren authored and GitHub committed 2023-05-24 15:10:59 +02:00
1 parent 7f4c39c8db
commit 9c8666a5c9
1 file changed
+9
+9
View File
@@ -4263,6 +4263,15 @@ impl Surface {
#[repr(transparent)]
pub struct Id<T>(core::num::NonZeroU64, std::marker::PhantomData<*mut T>);
// SAFETY: `Id` is a bare `NonZeroU64`, the type parameter is a marker purely to avoid confusing Ids
// returned for different types , so `Id` can safely implement Send and Sync.
#[cfg(feature = "expose-ids")]
unsafe impl<T> Send for Id<T> {}
// SAFETY: See the implementation for `Send`.
#[cfg(feature = "expose-ids")]
unsafe impl<T> Sync for Id<T> {}
#[cfg(feature = "expose-ids")]
impl<T> Clone for Id<T> {
fn clone(&self) -> Self {