X-Git-Url: https://code.octet-stream.net/netwatcher/blobdiff_plain/9ea683eddb05362f02bca60e4337955dfc5871dc..d2c9a9f306a336aa9dd8ddfb6579746e4f10b7a4:/src/watch_win.rs?ds=sidebyside diff --git a/src/watch_win.rs b/src/watch_win.rs index 41612b8..23b274e 100644 --- a/src/watch_win.rs +++ b/src/watch_win.rs @@ -23,7 +23,7 @@ struct WatchState { /// The last result that we captured, for diffing prev_list: List, /// User's callback - cb: Box, + cb: Box, } pub(crate) struct WatchHandle { @@ -39,7 +39,7 @@ impl Drop for WatchHandle { } } -pub(crate) fn watch_interfaces( +pub(crate) fn watch_interfaces( callback: F, ) -> Result { let state = Box::pin(Mutex::new(WatchState { @@ -81,7 +81,11 @@ unsafe extern "system" fn notif( ) { let state_ptr = ctx as *const Mutex; unsafe { - let state_guard = &mut *state_ptr.as_ref().unwrap().lock().unwrap(); + let state_guard = &mut *state_ptr + .as_ref() + .expect("callback ctx should never be null") + .lock() + .unwrap(); handle_notif(state_guard); } }