add log and use error! in Drop of Handle to let users choose if they want to care about failed CloseHandle

This commit is contained in:
2024-12-31 08:33:11 +00:00
parent 4b56a9ddfc
commit ffd8da0343
2 changed files with 5 additions and 6 deletions
+4 -6
View File
@@ -21,12 +21,10 @@ impl Deref for Handle {
impl Drop for Handle {
fn drop(&mut self) {
if self.0 != INVALID_HANDLE_VALUE {
unsafe {
if let Err(why) = CloseHandle(**self) {
eprintln!("failed to close handle: {why}");
};
}
unsafe {
if let Err(why) = CloseHandle(**self) {
log::error!("failed to close handle: {why}");
};
}
}
}