convert the last lossy casts to checked ones
This commit is contained in:
@@ -28,7 +28,7 @@ unsafe fn visible_window_rect(hwnd: HWND) -> Option<RECT> {
|
||||
hwnd,
|
||||
DWMWA_EXTENDED_FRAME_BOUNDS,
|
||||
(&raw mut rect).cast::<std::ffi::c_void>(),
|
||||
size_of::<RECT>() as u32,
|
||||
u32::try_from(size_of::<RECT>()).unwrap_or(0),
|
||||
)
|
||||
};
|
||||
if r.is_ok() && rect.right > rect.left && rect.bottom > rect.top {
|
||||
@@ -91,7 +91,9 @@ unsafe fn class_of(hwnd: HWND) -> String {
|
||||
if n <= 0 {
|
||||
return String::new();
|
||||
}
|
||||
String::from_utf16_lossy(&buf[..n as usize])
|
||||
// n came back from GetClassNameW as a positive count of units written, and
|
||||
// buf is 128 units, so this cannot exceed the slice either way.
|
||||
String::from_utf16_lossy(&buf[..usize::try_from(n).unwrap_or(0)])
|
||||
}
|
||||
|
||||
/// `EnumWindows` callback: records the first top-level window containing the
|
||||
|
||||
Reference in New Issue
Block a user