Assert at compile-time that WindowHandle is Sync
This commit is contained in:
parent
b79a7fbcf5
commit
1ea32123ed
|
@ -17,6 +17,7 @@ license = "MIT OR Apache-2.0"
|
|||
log = "0.4.11"
|
||||
keyboard-types = { version = "0.5.0", default-features = false }
|
||||
raw-window-handle = "0.3.3"
|
||||
static_assertions = "1.1.0"
|
||||
|
||||
[target.'cfg(target_os="linux")'.dependencies]
|
||||
xcb = { version = "0.9", features = ["thread", "xlib_xcb", "dri2"] }
|
||||
|
|
|
@ -57,4 +57,33 @@ unsafe impl <'a>HasRawWindowHandle for Window<'a> {
|
|||
fn raw_window_handle(&self) -> RawWindowHandle {
|
||||
self.0.raw_window_handle()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Compile-time API assertions
|
||||
#[doc(hidden)]
|
||||
mod assertions {
|
||||
use crate::{WindowHandle, WindowHandler, Event, Window};
|
||||
|
||||
struct TestWindowHandler {
|
||||
#[allow(dead_code)]
|
||||
ptr: *mut ::std::ffi::c_void,
|
||||
}
|
||||
|
||||
impl WindowHandler for TestWindowHandler {
|
||||
type Message = ();
|
||||
|
||||
fn on_event(&mut self, _: &mut Window, _: Event) {
|
||||
|
||||
}
|
||||
fn on_message(&mut self, _: &mut Window, _: Self::Message) {
|
||||
|
||||
}
|
||||
fn on_frame(&mut self) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static_assertions::assert_not_impl_any!(TestWindowHandler: Send);
|
||||
static_assertions::assert_impl_all!(WindowHandle<TestWindowHandler>: Send);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue