From 565e5fdfeb05a0fea8dd207c9e637185f5084aa4 Mon Sep 17 00:00:00 2001 From: psincf <44228825+psincf@users.noreply.github.com> Date: Wed, 1 May 2019 12:15:23 +0200 Subject: [PATCH] make trait TypedId:From --- wgpu-native/src/hub.rs | 10 +++++----- wgpu-native/src/lib.rs | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/wgpu-native/src/hub.rs b/wgpu-native/src/hub.rs index 941b8b37db..f07e5ec1e4 100644 --- a/wgpu-native/src/hub.rs +++ b/wgpu-native/src/hub.rs @@ -137,13 +137,13 @@ impl Storage { } } -pub struct Registry> { +pub struct Registry { #[cfg(feature = "local")] identity: Mutex, data: RwLock>, } -impl> Default for Registry { +impl Default for Registry { fn default() -> Self { Registry { #[cfg(feature = "local")] @@ -153,20 +153,20 @@ impl> Default for Registry { } } -impl> ops::Deref for Registry { +impl ops::Deref for Registry { type Target = RwLock>; fn deref(&self) -> &Self::Target { &self.data } } -impl> ops::DerefMut for Registry { +impl ops::DerefMut for Registry { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.data } } -impl + Clone> Registry { +impl Registry { pub fn register(&self, id: I, value: T) { let old = self.data.write().map.insert(id.raw().0 as usize, (value, id.raw().1)); assert!(old.is_none()); diff --git a/wgpu-native/src/lib.rs b/wgpu-native/src/lib.rs index 7493304a7d..fb6638e6e7 100644 --- a/wgpu-native/src/lib.rs +++ b/wgpu-native/src/lib.rs @@ -185,22 +185,22 @@ macro_rules! transparent { ) } -pub trait TypedId { +pub trait TypedId:From { fn raw(&self) -> Id; } macro_rules! typed_id { - ($i:ident) => ( - impl TypedId for $i { - fn raw(&self) -> Id { - self.0 - } - } + ($i:ident) => ( impl From for $i { fn from(id:Id) -> $i { $i(id) } } + impl TypedId for $i { + fn raw(&self) -> Id { + self.0 + } + } ) }