diff --git a/examples/image.rs b/examples/image.rs index 7d005f0..0466db8 100644 --- a/examples/image.rs +++ b/examples/image.rs @@ -9,13 +9,13 @@ fn main() { decoder.set_transformations(Transformations::ALPHA); let mut reader = decoder.read_info().unwrap(); - let mut buffer = vec![0u32; reader.output_buffer_size()]; + let mut buffer = vec![0u32; reader.output_buffer_size() / 4]; // View of pixels as individual subpixels (avoids allocating a second pixel buffer). let mut u8_buffer = unsafe { std::slice::from_raw_parts_mut( buffer.as_mut_ptr() as *mut u8, - buffer.len() * std::mem::size_of::(), + std::mem::size_of_val(&buffer), ) }; diff --git a/src/key_handler.rs b/src/key_handler.rs index 72e046d..f74b0f1 100644 --- a/src/key_handler.rs +++ b/src/key_handler.rs @@ -6,7 +6,7 @@ use instant::{Duration, Instant}; #[cfg(not(feature = "web"))] use std::time::{Duration, Instant}; -use crate::{InputCallback, Key, KeyRepeat}; +use crate::{key, InputCallback, Key, KeyRepeat}; pub struct KeyHandler { pub key_callback: Option>, @@ -47,7 +47,7 @@ impl KeyHandler { for (idx, is_down) in self.keys.iter().enumerate() { if *is_down { unsafe { - keys.push(std::mem::transmute(idx as u8)); + keys.push(std::mem::transmute::(idx as u8)); } } } @@ -85,7 +85,7 @@ impl KeyHandler { for (idx, is_down) in self.keys.iter().enumerate() { if *is_down && self.is_key_index_pressed(idx, repeat) { unsafe { - keys.push(std::mem::transmute(idx as u8)); + keys.push(std::mem::transmute::(idx as u8)); } } } @@ -99,7 +99,7 @@ impl KeyHandler { for (idx, is_down) in self.keys.iter().enumerate() { if !(*is_down) && self.is_key_index_released(idx) { unsafe { - keys.push(std::mem::transmute(idx as u8)); + keys.push(std::mem::transmute::(idx as u8)); } } } diff --git a/src/lib.rs b/src/lib.rs index 1782a34..3f15234 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -527,7 +527,7 @@ impl Window { /// ``` #[inline] #[deprecated( - since = "0.26", + since = "0.26.0", note = "use `set_target_fps` instead, this function will be removed in the future" )] pub fn limit_update_rate(&mut self, time: Option) { diff --git a/src/os/posix/wayland.rs b/src/os/posix/wayland.rs index cd8f85c..0916e81 100644 --- a/src/os/posix/wayland.rs +++ b/src/os/posix/wayland.rs @@ -218,10 +218,7 @@ impl DisplayInfo { // Add a black canvas into the framebuffer let frame: Vec = vec![0xFF00_0000; (size.0 * size.1) as usize]; let slice = unsafe { - std::slice::from_raw_parts( - frame.as_ptr() as *const u8, - frame.len() * std::mem::size_of::(), - ) + std::slice::from_raw_parts(frame.as_ptr() as *const u8, std::mem::size_of_val(&frame)) }; tempfile .write_all(slice) @@ -276,7 +273,7 @@ impl DisplayInfo { // Give the buffer to the surface and commit surface.attach(Some(buffer), 0, 0); - surface.damage(0, 0, i32::max_value(), i32::max_value()); + surface.damage(0, 0, i32::MAX, i32::MAX); surface.commit(); let xdg_config = Rc::new(RefCell::new(None)); @@ -348,10 +345,7 @@ impl DisplayInfo { fd.seek(SeekFrom::Start(0))?; let slice = unsafe { - std::slice::from_raw_parts( - buffer.as_ptr() as *const u8, - buffer.len() * std::mem::size_of::(), - ) + std::slice::from_raw_parts(buffer.as_ptr() as *const u8, std::mem::size_of_val(buffer)) }; fd.write_all(slice)?; @@ -363,8 +357,7 @@ impl DisplayInfo { } self.surface.attach(Some(buf), 0, 0); - self.surface - .damage(0, 0, i32::max_value(), i32::max_value()); + self.surface.damage(0, 0, i32::MAX, i32::MAX); self.surface.commit(); Ok(()) diff --git a/src/os/posix/x11.rs b/src/os/posix/x11.rs index 01f697d..cf1b0bf 100644 --- a/src/os/posix/x11.rs +++ b/src/os/posix/x11.rs @@ -1200,7 +1200,7 @@ impl Window { } fn update_key_state(&mut self, sym: xlib::KeySym, is_down: bool) { - if sym > u32::max_value() as xlib::KeySym { + if sym > u32::MAX as xlib::KeySym { return; } diff --git a/src/os/wasm/mod.rs b/src/os/wasm/mod.rs index a54e15f..8411cdc 100644 --- a/src/os/wasm/mod.rs +++ b/src/os/wasm/mod.rs @@ -25,12 +25,7 @@ use web_sys::{window, CanvasRenderingContext2d, HtmlCanvasElement, ImageData}; #[inline(always)] #[allow(dead_code)] // Only used on 32-bit builds currently pub fn u32_as_u8<'a>(src: &'a [u32]) -> &'a [u8] { - unsafe { - std::slice::from_raw_parts( - src.as_ptr() as *mut u8, - src.len() * std::mem::size_of::(), - ) - } + unsafe { std::slice::from_raw_parts(src.as_ptr() as *mut u8, std::mem::size_of_val(&src)) } } struct MouseState {