Skip to content

Commit

Permalink
use NonNull::cast instead of as where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
matzemathics committed Jan 15, 2024
1 parent 28d018a commit 528d04c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ impl<T, const N: usize> SmallVec<T, N> {
// so the copy is within bounds of the inline member
copy_nonoverlapping(ptr.as_ptr(), self.raw.as_mut_ptr_inline(), len);
drop(DropDealloc {
ptr: NonNull::new_unchecked(ptr.as_ptr() as *mut u8),
ptr: NonNull::new_unchecked(ptr.cast().as_ptr()),
size_bytes: old_cap * size_of::<T>(),
align: align_of::<T>(),
});
Expand Down Expand Up @@ -909,7 +909,7 @@ impl<T, const N: usize> SmallVec<T, N> {
copy_nonoverlapping(ptr.as_ptr(), self.raw.as_mut_ptr_inline(), len);
self.set_inline();
alloc::alloc::dealloc(
ptr.as_ptr() as *mut u8,
ptr.cast().as_ptr(),
Layout::from_size_align_unchecked(capacity * size_of::<T>(), align_of::<T>()),
);
}
Expand Down

0 comments on commit 528d04c

Please sign in to comment.