From 87d58ecbe9272178d09b329f39ce7fdc1e7afd6f Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Fri, 9 Feb 2024 22:05:25 -0500 Subject: [PATCH] Use a bit less NonNull::new_unchecked --- src/raw/mod.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/raw/mod.rs b/src/raw/mod.rs index 711fb89d0..ddd4fe7c1 100644 --- a/src/raw/mod.rs +++ b/src/raw/mod.rs @@ -919,9 +919,7 @@ impl RawTable { /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html #[inline] pub fn data_end(&self) -> NonNull { - // SAFETY: `self.table.ctrl` is `NonNull`, so casting it is safe - // - // `self.table.ctrl.as_ptr().cast()` returns pointer that + // `self.table.ctrl.cast()` returns pointer that // points here (to the end of `T0`) // ∨ // [Pad], T_n, ..., T1, T0, |CT0, CT1, ..., CT_n|, CTa_0, CTa_1, ..., CTa_m @@ -938,7 +936,7 @@ impl RawTable { // // P.S. `h1(hash) & self.bucket_mask` is the same as `hash as usize % self.buckets()` because the number // of buckets is a power of two, and `self.bucket_mask = self.buckets() - 1`. - unsafe { NonNull::new_unchecked(self.table.ctrl.as_ptr().cast()) } + self.table.ctrl.cast() } /// Returns pointer to start of data table. @@ -2595,10 +2593,7 @@ impl RawTableInner { /// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html #[inline] fn data_end(&self) -> NonNull { - unsafe { - // SAFETY: `self.ctrl` is `NonNull`, so casting it is safe - NonNull::new_unchecked(self.ctrl.as_ptr().cast()) - } + self.ctrl.cast() } /// Returns an iterator-like object for a probe sequence on the table.