Skip to content

Commit

Permalink
Implement Send and Sync unconditionally for exposed Id type. (#3801)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyren authored May 24, 2023
1 parent 7f4c39c commit 9c8666a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9c8666a

Please sign in to comment.