From 458e63551365c5afcb9bdf1b80eeed95f7c92e3e Mon Sep 17 00:00:00 2001 From: Max Guppy Date: Thu, 30 Mar 2023 20:56:51 +1000 Subject: [PATCH] Manually implement traits on `wgpu::Id` --- wgpu/src/lib.rs | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index e9c700053c..2c1c9cc9c6 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -4243,9 +4243,42 @@ impl Surface { #[cfg(feature = "expose-ids")] #[cfg_attr(docsrs, doc(cfg(feature = "expose-ids")))] #[repr(transparent)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Id(core::num::NonZeroU64, std::marker::PhantomData<*mut T>); +#[cfg(feature = "expose-ids")] +impl Clone for Id { + fn clone(&self) -> Self { + *self + } +} + +#[cfg(feature = "expose-ids")] +impl Copy for Id {} + +#[cfg(feature = "expose-ids")] +impl Debug for Id { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_tuple("Id").field(&self.0).finish() + } +} + +#[cfg(feature = "expose-ids")] +impl PartialEq for Id { + fn eq(&self, other: &Id) -> bool { + self.0 == other.0 + } +} + +#[cfg(feature = "expose-ids")] +impl Eq for Id {} + +#[cfg(feature = "expose-ids")] +impl std::hash::Hash for Id { + fn hash(&self, state: &mut H) { + self.0.hash(state) + } +} + #[cfg(feature = "expose-ids")] impl Adapter { /// Returns a globally-unique identifier for this `Adapter`.