mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Manually implement traits on wgpu::Id (#3630)
This commit is contained in:
parent
fdbbd02c1e
commit
47a887ce0f
@ -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<T>(core::num::NonZeroU64, std::marker::PhantomData<*mut T>);
|
||||
|
||||
#[cfg(feature = "expose-ids")]
|
||||
impl<T> Clone for Id<T> {
|
||||
fn clone(&self) -> Self {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "expose-ids")]
|
||||
impl<T> Copy for Id<T> {}
|
||||
|
||||
#[cfg(feature = "expose-ids")]
|
||||
impl<T> Debug for Id<T> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
f.debug_tuple("Id").field(&self.0).finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "expose-ids")]
|
||||
impl<T> PartialEq for Id<T> {
|
||||
fn eq(&self, other: &Id<T>) -> bool {
|
||||
self.0 == other.0
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "expose-ids")]
|
||||
impl<T> Eq for Id<T> {}
|
||||
|
||||
#[cfg(feature = "expose-ids")]
|
||||
impl<T> std::hash::Hash for Id<T> {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.0.hash(state)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "expose-ids")]
|
||||
impl Adapter {
|
||||
/// Returns a globally-unique identifier for this `Adapter`.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user