Skip to content

Commit 4a89128

Browse files
committed
implement drop for SimConnector
1 parent bd4baa2 commit 4a89128

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ pub enum DispatchResult<'a> {
103103

104104
/// Handles communication between the client program and SimConnect
105105
/// For more information about the functions provided, refer to the SimConnect SDK Documentation. The functions name closely match up with those defined there.
106-
#[derive(Copy, Clone)]
107106
pub struct SimConnector {
108107
sim_connect_handle: HANDLE
109108
}
@@ -517,4 +516,14 @@ impl SimConnector {
517516
}
518517
}
519518
}
519+
}
520+
521+
impl Drop for SimConnector {
522+
fn drop(&mut self) {
523+
if !self.sim_connect_handle.is_null() {
524+
unsafe {
525+
SimConnect_Close(self.sim_connect_handle);
526+
}
527+
}
528+
}
520529
}

0 commit comments

Comments
 (0)