From 87f2174b6907bc037dbbaa32d6881cb8c0b71e25 Mon Sep 17 00:00:00 2001 From: John Nunley Date: Sat, 2 Sep 2023 08:30:22 -0700 Subject: [PATCH] Implement HasRaw*Handle for all Has*Handle Signed-off-by: John Nunley --- src/borrowed.rs | 14 ------------- src/lib.rs | 55 ++++--------------------------------------------- 2 files changed, 4 insertions(+), 65 deletions(-) diff --git a/src/borrowed.rs b/src/borrowed.rs index 65b5521..62f9092 100644 --- a/src/borrowed.rs +++ b/src/borrowed.rs @@ -82,13 +82,6 @@ pub struct DisplayHandle<'a> { _marker: PhantomData<&'a *const ()>, } -#[allow(deprecated)] -unsafe impl crate::HasRawDisplayHandle for DisplayHandle<'_> { - fn raw_display_handle(&self) -> Result { - Ok(self.raw) - } -} - impl fmt::Debug for DisplayHandle<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("DisplayHandle").field(&self.raw).finish() @@ -264,13 +257,6 @@ impl<'a> WindowHandle<'a> { } } -#[allow(deprecated)] -unsafe impl crate::HasRawWindowHandle for WindowHandle<'_> { - fn raw_window_handle(&self) -> Result { - Ok(self.raw.clone()) - } -} - impl AsRef for WindowHandle<'_> { fn as_ref(&self) -> &RawWindowHandle { &self.raw diff --git a/src/lib.rs b/src/lib.rs index 3bb68c4..6494846 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,31 +77,9 @@ pub unsafe trait HasRawWindowHandle { } #[allow(deprecated)] -unsafe impl<'a, T: HasRawWindowHandle + ?Sized> HasRawWindowHandle for &'a T { +unsafe impl HasRawWindowHandle for T { fn raw_window_handle(&self) -> Result { - (*self).raw_window_handle() - } -} -#[allow(deprecated)] -unsafe impl<'a, T: HasRawWindowHandle + ?Sized> HasRawWindowHandle for &'a mut T { - fn raw_window_handle(&self) -> Result { - (**self).raw_window_handle() - } -} -#[cfg(feature = "alloc")] -#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] -#[allow(deprecated)] -unsafe impl HasRawWindowHandle for alloc::rc::Rc { - fn raw_window_handle(&self) -> Result { - (**self).raw_window_handle() - } -} -#[cfg(feature = "alloc")] -#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] -#[allow(deprecated)] -unsafe impl HasRawWindowHandle for alloc::sync::Arc { - fn raw_window_handle(&self) -> Result { - (**self).raw_window_handle() + self.window_handle().map(Into::into) } } @@ -227,34 +205,9 @@ pub unsafe trait HasRawDisplayHandle { } #[allow(deprecated)] -unsafe impl<'a, T: HasRawDisplayHandle + ?Sized> HasRawDisplayHandle for &'a T { - fn raw_display_handle(&self) -> Result { - (*self).raw_display_handle() - } -} - -#[allow(deprecated)] -unsafe impl<'a, T: HasRawDisplayHandle + ?Sized> HasRawDisplayHandle for &'a mut T { - fn raw_display_handle(&self) -> Result { - (**self).raw_display_handle() - } -} - -#[cfg(feature = "alloc")] -#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] -#[allow(deprecated)] -unsafe impl HasRawDisplayHandle for alloc::rc::Rc { - fn raw_display_handle(&self) -> Result { - (**self).raw_display_handle() - } -} - -#[cfg(feature = "alloc")] -#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] -#[allow(deprecated)] -unsafe impl HasRawDisplayHandle for alloc::sync::Arc { +unsafe impl HasRawDisplayHandle for T { fn raw_display_handle(&self) -> Result { - (**self).raw_display_handle() + self.display_handle().map(Into::into) } }