use handle.is_invalid() instead of comparison

This commit is contained in:
2025-12-07 11:36:44 +00:00
parent cb1c6b936e
commit 1ed4cc4980
+2 -2
View File
@@ -1,7 +1,7 @@
use crate::error::Error; use crate::error::Error;
use derive_more::Deref; use derive_more::Deref;
use windows::Win32::{ use windows::Win32::{
Foundation::{CloseHandle, HANDLE, INVALID_HANDLE_VALUE}, Foundation::{CloseHandle, HANDLE},
System::Threading::{OpenProcess, PROCESS_ALL_ACCESS, PROCESS_VM_READ, PROCESS_VM_WRITE}, System::Threading::{OpenProcess, PROCESS_ALL_ACCESS, PROCESS_VM_READ, PROCESS_VM_WRITE},
}; };
@@ -28,7 +28,7 @@ impl Handle {
"failed to open process with needed access: {why}", "failed to open process with needed access: {why}",
)) ))
})?; })?;
if handle == INVALID_HANDLE_VALUE { if handle.is_invalid() {
return Err(Error::ObtainHandleError( return Err(Error::ObtainHandleError(
"failed to get a valid handle".to_string(), "failed to get a valid handle".to_string(),
)); ));