diff --git a/wgpu-core/src/id.rs b/wgpu-core/src/id.rs index a18510ef2..76b83e5fa 100644 --- a/wgpu-core/src/id.rs +++ b/wgpu-core/src/id.rs @@ -129,7 +129,10 @@ impl TryFrom for RawId { #[allow(dead_code)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug)] -pub struct PointerId(usize, #[serde(skip)] PhantomData); +pub enum PointerId { + // The only variant forces RON to not ignore "Id" + PointerId(usize, #[serde(skip)] PhantomData), +} impl Copy for PointerId {} @@ -141,7 +144,9 @@ impl Clone for PointerId { impl PartialEq for PointerId { fn eq(&self, other: &Self) -> bool { - self.0 == other.0 + let PointerId::PointerId(this, _) = self; + let PointerId::PointerId(other, _) = other; + this == other } } @@ -149,7 +154,8 @@ impl Eq for PointerId {} impl Hash for PointerId { fn hash(&self, state: &mut H) { - self.0.hash(state); + let PointerId::PointerId(this, _) = self; + this.hash(state); } } @@ -161,7 +167,7 @@ impl From<&Arc> for PointerId { // Unfortunately, because `Arc::as_ptr` returns a pointer to the // contained data, and `Arc` stores reference counts before the data, // we are adding an offset to the pointer here. - Self(Arc::as_ptr(arc) as usize, PhantomData) + PointerId::PointerId(Arc::as_ptr(arc) as usize, PhantomData) } }