Skip to content

Commit

Permalink
Remove unnecessary PhantomData from platform::WindowHandle definitions (
Browse files Browse the repository at this point in the history
#163)

These `PhantomData` fields are redundant, as the public `WindowHandle` struct already contains one.
  • Loading branch information
micahrj authored Dec 17, 2023
1 parent 7d14a55 commit 937ef96
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 19 deletions.
5 changes: 0 additions & 5 deletions src/macos/window.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::cell::{Cell, RefCell};
use std::ffi::c_void;
use std::marker::PhantomData;
use std::ptr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
Expand Down Expand Up @@ -38,9 +37,6 @@ pub struct WindowHandle {
raw_window_handle: Option<RawWindowHandle>,
close_requested: Arc<AtomicBool>,
is_open: Arc<AtomicBool>,

// Ensure handle is !Send
_phantom: PhantomData<*mut ()>,
}

impl WindowHandle {
Expand Down Expand Up @@ -81,7 +77,6 @@ impl ParentHandle {
raw_window_handle: Some(raw_window_handle),
close_requested: Arc::clone(&close_requested),
is_open: Arc::clone(&is_open),
_phantom: PhantomData::default(),
};

(Self { _close_requested: close_requested, is_open }, handle)
Expand Down
10 changes: 1 addition & 9 deletions src/win/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use winapi::um::winuser::{
use std::cell::{Cell, Ref, RefCell, RefMut};
use std::collections::VecDeque;
use std::ffi::{c_void, OsStr};
use std::marker::PhantomData;
use std::os::windows::ffi::OsStrExt;
use std::ptr::null_mut;
use std::rc::Rc;
Expand Down Expand Up @@ -68,9 +67,6 @@ const WIN_FRAME_TIMER: usize = 4242;
pub struct WindowHandle {
hwnd: Option<HWND>,
is_open: Rc<Cell<bool>>,

// Ensure handle is !Send
_phantom: PhantomData<*mut ()>,
}

impl WindowHandle {
Expand Down Expand Up @@ -108,11 +104,7 @@ impl ParentHandle {
pub fn new(hwnd: HWND) -> (Self, WindowHandle) {
let is_open = Rc::new(Cell::new(true));

let handle = WindowHandle {
hwnd: Some(hwnd),
is_open: Rc::clone(&is_open),
_phantom: PhantomData::default(),
};
let handle = WindowHandle { hwnd: Some(hwnd), is_open: Rc::clone(&is_open) };

(Self { is_open }, handle)
}
Expand Down
5 changes: 0 additions & 5 deletions src/x11/window.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::ffi::c_void;
use std::marker::PhantomData;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc;
use std::sync::Arc;
Expand Down Expand Up @@ -28,9 +27,6 @@ pub struct WindowHandle {
raw_window_handle: Option<RawWindowHandle>,
close_requested: Arc<AtomicBool>,
is_open: Arc<AtomicBool>,

// Ensure handle is !Send
_phantom: PhantomData<*mut ()>,
}

impl WindowHandle {
Expand Down Expand Up @@ -75,7 +71,6 @@ impl ParentHandle {
raw_window_handle: None,
close_requested: Arc::clone(&close_requested),
is_open: Arc::clone(&is_open),
_phantom: PhantomData::default(),
};

(Self { close_requested, is_open }, handle)
Expand Down

0 comments on commit 937ef96

Please sign in to comment.