From 66739fd6422b424607fb0d8166647afdf0aaac7c Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Sat, 9 Dec 2023 23:29:58 +0700 Subject: [PATCH] rust: Fix manual_slice_size_calculation lint. See: https://rust-lang.github.io/rust-clippy/master/index.html#/manual_slice_size_calculation --- bindgen/gen_rust.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindgen/gen_rust.py b/bindgen/gen_rust.py index 0b6384c45..9349152be 100644 --- a/bindgen/gen_rust.py +++ b/bindgen/gen_rust.py @@ -766,7 +766,7 @@ def gen_helpers(inp): if inp['prefix'] in ['sg_', 'sdtx_', 'sshape_', 'sapp_']: l("/// Helper function to cast a rust slice into a sokol Range") l(f"pub fn slice_as_range(data: &[T]) -> {range_struct_name} {{") - l(f" {range_struct_name} {{ size: data.len() * std::mem::size_of::(), ptr: data.as_ptr() as *const _ }}") + l(f" {range_struct_name} {{ size: std::mem::size_of_val(data), ptr: data.as_ptr() as *const _ }}") l("}") l("/// Helper function to cast a rust reference into a sokol Range") l(f"pub fn value_as_range(value: &T) -> {range_struct_name} {{")