From ec925f62bea23a67c4ce5efa2c37b0c63f97d50d Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sun, 30 Jul 2023 20:37:17 +0200 Subject: [PATCH] Make XcbWindowHandle use `NonZeroU32` --- src/unix.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/unix.rs b/src/unix.rs index 0dd4773..43cf9b4 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -1,3 +1,4 @@ +use core::num::NonZeroU32; use core::ffi::{c_int, c_ulong, c_void}; use core::ptr::NonNull; @@ -114,9 +115,9 @@ impl XcbDisplayHandle { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct XcbWindowHandle { /// An X11 `xcb_window_t`. - pub window: u32, // Based on xproto.h - /// An X11 `xcb_visualid_t`, or 0 if unknown. - pub visual_id: u32, + pub window: NonZeroU32, // Based on xproto.h + /// An X11 `xcb_visualid_t`. + pub visual_id: Option, } impl XcbWindowHandle { @@ -129,15 +130,15 @@ impl XcbWindowHandle { /// # use raw_window_handle::XcbWindowHandle; /// # /// let window: u32; - /// # window = 0; + /// # window = NonZeroU32::new(1).unwrap(); /// let mut handle = XcbWindowHandle::new(window); /// // Optionally set the visual ID. - /// handle.visual_id = 0; + /// handle.visual_id = None; /// ``` - pub fn new(window: u32) -> Self { + pub fn new(window: NonZeroU32) -> Self { Self { window, - visual_id: 0, + visual_id: None, } } }