Skip to content

Commit 87d58ec

Browse files
committed
Use a bit less NonNull::new_unchecked
1 parent 877bcf6 commit 87d58ec

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/raw/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -919,9 +919,7 @@ impl<T, A: Allocator> RawTable<T, A> {
919919
/// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
920920
#[inline]
921921
pub fn data_end(&self) -> NonNull<T> {
922-
// SAFETY: `self.table.ctrl` is `NonNull`, so casting it is safe
923-
//
924-
// `self.table.ctrl.as_ptr().cast()` returns pointer that
922+
// `self.table.ctrl.cast()` returns pointer that
925923
// points here (to the end of `T0`)
926924
// ∨
927925
// [Pad], T_n, ..., T1, T0, |CT0, CT1, ..., CT_n|, CTa_0, CTa_1, ..., CTa_m
@@ -938,7 +936,7 @@ impl<T, A: Allocator> RawTable<T, A> {
938936
//
939937
// P.S. `h1(hash) & self.bucket_mask` is the same as `hash as usize % self.buckets()` because the number
940938
// of buckets is a power of two, and `self.bucket_mask = self.buckets() - 1`.
941-
unsafe { NonNull::new_unchecked(self.table.ctrl.as_ptr().cast()) }
939+
self.table.ctrl.cast()
942940
}
943941

944942
/// Returns pointer to start of data table.
@@ -2595,10 +2593,7 @@ impl RawTableInner {
25952593
/// [`undefined behavior`]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
25962594
#[inline]
25972595
fn data_end<T>(&self) -> NonNull<T> {
2598-
unsafe {
2599-
// SAFETY: `self.ctrl` is `NonNull`, so casting it is safe
2600-
NonNull::new_unchecked(self.ctrl.as_ptr().cast())
2601-
}
2596+
self.ctrl.cast()
26022597
}
26032598

26042599
/// Returns an iterator-like object for a probe sequence on the table.

0 commit comments

Comments
 (0)