Skip to content

Commit

Permalink
Remove unneeded boxing
Browse files Browse the repository at this point in the history
  • Loading branch information
haimgel committed Oct 25, 2023
1 parent 2369a31 commit 9f4c4bb
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(Box::new(self));
let pnp_detector = PnPDetect::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 {
pub struct PnPDetectWindows<'a> {
hwnd: HWND,
callback: Box<dyn UsbCallback>,
callback: &'a dyn UsbCallback,
current_devices: HashSet<String>,
}

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

0 comments on commit 9f4c4bb

Please sign in to comment.