From 47a887ce0ff2c857aaa4ed1d258f967127aa6aa2 Mon Sep 17 00:00:00 2001 From: TheOnlyMrCat Date: Thu, 6 Apr 2023 07:56:04 +1000 Subject: [PATCH] Manually implement traits on `wgpu::Id` (#3630) --- 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 a74ee0d58b..253262dc7e 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`.