From e7a90c51a113b9cfc905d3ce07299eafbf792d0f Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Wed, 11 Oct 2023 17:31:20 +0200 Subject: [PATCH] Use `size_of_val` on slices for binary size --- src/device.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/device.rs b/src/device.rs index 824be6e..34582a5 100644 --- a/src/device.rs +++ b/src/device.rs @@ -276,19 +276,19 @@ impl Device { } control::Value::CompoundU8(ref val) => { control.__bindgen_anon_1.p_u8 = val.as_ptr() as *mut u8; - control.size = (val.len() * std::mem::size_of::()) as u32; + control.size = std::mem::size_of_val(val.as_slice()) as u32; } control::Value::CompoundU16(ref val) => { control.__bindgen_anon_1.p_u16 = val.as_ptr() as *mut u16; - control.size = (val.len() * std::mem::size_of::()) as u32; + control.size = std::mem::size_of_val(val.as_slice()) as u32; } control::Value::CompoundU32(ref val) => { control.__bindgen_anon_1.p_u32 = val.as_ptr() as *mut u32; - control.size = (val.len() * std::mem::size_of::()) as u32; + control.size = std::mem::size_of_val(val.as_slice()) as u32; } control::Value::CompoundPtr(ref val) => { control.__bindgen_anon_1.ptr = val.as_ptr() as *mut std::os::raw::c_void; - control.size = (val.len() * std::mem::size_of::()) as u32; + control.size = std::mem::size_of_val(val.as_slice()) as u32; } };