From 8c3fe94a6d3e9480b30dada3a2f727ec2276cae5 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sat, 14 Oct 2023 00:08:18 +0200 Subject: [PATCH] Breaking: Make WebWindowHandle and Win32WindowHandle !Send and !Sync --- src/lib.rs | 4 ++-- src/web.rs | 7 ++++++- src/windows.rs | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index ef3871b..636cba0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -463,9 +463,9 @@ mod tests { assert_not_impl_any!(WaylandWindowHandle: Send, Sync); assert_impl_all!(DrmWindowHandle: Send, Sync); assert_not_impl_any!(GbmWindowHandle: Send, Sync); - assert_impl_all!(Win32WindowHandle: Send, Sync); + assert_not_impl_any!(Win32WindowHandle: Send, Sync); assert_not_impl_any!(WinRtWindowHandle: Send, Sync); - assert_impl_all!(WebWindowHandle: Send, Sync); + assert_not_impl_any!(WebWindowHandle: Send, Sync); assert_not_impl_any!(WebCanvasWindowHandle: Send, Sync); assert_not_impl_any!(WebOffscreenCanvasWindowHandle: Send, Sync); assert_not_impl_any!(AndroidNdkWindowHandle: Send, Sync); diff --git a/src/web.rs b/src/web.rs index 9e782a8..34c5de7 100644 --- a/src/web.rs +++ b/src/web.rs @@ -1,4 +1,5 @@ use core::ffi::c_void; +use core::marker::PhantomData; use core::ptr::NonNull; /// Raw display handle for the Web. @@ -33,6 +34,7 @@ pub struct WebWindowHandle { /// /// [data attributes]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/data-* pub id: u32, + _marker: PhantomData<*const ()>, } impl WebWindowHandle { @@ -48,7 +50,10 @@ impl WebWindowHandle { /// let handle = WebWindowHandle::new(id); /// ``` pub fn new(id: u32) -> Self { - Self { id } + Self { + id, + _marker: PhantomData, + } } } diff --git a/src/windows.rs b/src/windows.rs index 9751dbf..8475355 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -1,4 +1,5 @@ use core::ffi::c_void; +use core::marker::PhantomData; use core::num::NonZeroIsize; use core::ptr::NonNull; @@ -32,6 +33,7 @@ pub struct Win32WindowHandle { pub hwnd: NonZeroIsize, /// The `GWLP_HINSTANCE` associated with this type's `HWND`. pub hinstance: Option, + _marker: PhantomData<*const ()>, } impl Win32WindowHandle { @@ -58,6 +60,7 @@ impl Win32WindowHandle { Self { hwnd, hinstance: None, + _marker: PhantomData, } } }