diff --git a/rust-toolchain b/rust-toolchain index 9006c0b..f474f5a 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.70.0 \ No newline at end of file +1.71.0 \ No newline at end of file diff --git a/src/platform/pnp_detect_windows.rs b/src/platform/pnp_detect_windows.rs index baad0eb..0e5dd2e 100644 --- a/src/platform/pnp_detect_windows.rs +++ b/src/platform/pnp_detect_windows.rs @@ -29,12 +29,12 @@ pub struct PnPDetectWindows { } impl PnPDetectWindows { - pub fn new(callback: Box) -> Self { - let mut pnp_detect = Self { + pub fn new(callback: Box) -> Box { + let mut pnp_detect = Box::new(Self { callback, current_devices: Self::read_device_list().unwrap_or_default(), hwnd: std::ptr::null_mut(), - }; + }); pnp_detect.create_window(); return pnp_detect; } @@ -95,8 +95,8 @@ impl PnPDetectWindows { PostQuitMessage(0); } WM_DEVICECHANGE => { - let self_ptr = GetWindowLongPtrW(hwnd, GWLP_USERDATA) as *mut Self; - let window_state: &mut Self = self_ptr.as_mut().unwrap(); + let self_ptr = GetWindowLongPtrW(hwnd, GWLP_USERDATA); + let window_state: &mut Self = &mut *(self_ptr as *mut Self); window_state.handle_hotplug_event(); } _ => return DefWindowProcW(hwnd, msg, wparam, lparam), @@ -146,8 +146,7 @@ impl PnPDetectWindows { std::ptr::null_mut(), std::ptr::null_mut(), hinstance, - self as *mut Self as *mut winapi::ctypes::c_void, - //std::ptr::null_mut(), + self as *mut _ as *mut _, ) };