Skip to content

Commit

Permalink
Revert "Remove unneeded boxing"
Browse files Browse the repository at this point in the history
This boxing is not unneeded, it's actually
required by libusb on MacOS/Linux.

This reverts commit 9f4c4bb.
  • Loading branch information
haimgel committed Oct 28, 2023
1 parent 9f4c4bb commit 44acc86
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl App {

pub fn run(self) -> Result<()> {
display_control::log_current_source();
let pnp_detector = PnPDetect::new(&self);
let pnp_detector = PnPDetect::new(Box::new(self));
pnp_detector.detect()?;

Ok(())
Expand Down
8 changes: 4 additions & 4 deletions src/platform/pnp_detect_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ use winapi::um::winuser::{
/// Detection of plugged in / removed USB devices on Windows: listens for WM_DEVICECHANGE messages.
/// This code should be removed once libusb supports hotplug notifications on Windows:
/// https://github.com/libusb/libusb/issues/86
pub struct PnPDetectWindows<'a> {
pub struct PnPDetectWindows {
hwnd: HWND,
callback: &'a dyn UsbCallback,
callback: Box<dyn UsbCallback>,
current_devices: HashSet<String>,
}

impl<'a> PnPDetectWindows<'a> {
pub fn new(callback: &'a (dyn UsbCallback + 'a)) -> Self {
impl PnPDetectWindows {
pub fn new(callback: Box<dyn UsbCallback>) -> Self {
let mut pnp_detect = Self {
callback,
current_devices: Self::read_device_list().unwrap_or_default(),
Expand Down

0 comments on commit 44acc86

Please sign in to comment.