From 57c7b80414acc7f7b743274dfc02ab28c92ff573 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 10 Nov 2024 13:03:25 +0100 Subject: [PATCH] elem_offset / subslice_range: use addr() instead of 'as usize' --- core/src/slice/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/slice/mod.rs b/core/src/slice/mod.rs index 52d2179b04de1..ce9d04d01d7ed 100644 --- a/core/src/slice/mod.rs +++ b/core/src/slice/mod.rs @@ -4578,8 +4578,8 @@ impl [T] { panic!("elements are zero-sized"); } - let self_start = self.as_ptr() as usize; - let elem_start = element as *const T as usize; + let self_start = self.as_ptr().addr(); + let elem_start = ptr::from_ref(element).addr(); let byte_offset = elem_start.wrapping_sub(self_start); @@ -4631,8 +4631,8 @@ impl [T] { panic!("elements are zero-sized"); } - let self_start = self.as_ptr() as usize; - let subslice_start = subslice.as_ptr() as usize; + let self_start = self.as_ptr().addr(); + let subslice_start = subslice.as_ptr().addr(); let byte_start = subslice_start.wrapping_sub(self_start);