From 439b93dd3e22311caee6d69eb4aa1da5b81a0731 Mon Sep 17 00:00:00 2001 From: Nathan Ringo Date: Sat, 31 Aug 2024 23:30:46 -0500 Subject: Almost all of buddy initialization. --- crates/utils/src/pin.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/utils') diff --git a/crates/utils/src/pin.rs b/crates/utils/src/pin.rs index 202904d..cdf40fd 100644 --- a/crates/utils/src/pin.rs +++ b/crates/utils/src/pin.rs @@ -5,8 +5,11 @@ use core::pin::Pin; use std::ptr::NonNull; /// Iterates over projections of elements out of a pinned slice. -pub fn pin_project_slice_mut_iter(slice: Pin<&mut [T]>) -> impl Iterator> { - let base_ptr: NonNull = NonNull::from(slice.as_ref().get_ref()).cast(); +pub fn pin_project_slice_mut_iter( + mut slice: Pin<&mut [T]>, +) -> impl Iterator> { + // SAFETY: We never move out of this pointer. + let base_ptr: NonNull = NonNull::from(unsafe { slice.as_mut().get_unchecked_mut() }).cast(); (0..slice.len()).map(move |i| { // SAFETY: This is in-bounds, since the original slice was valid. No other references to // the data can exist, since we visit each index once and have an exclusive borrow on the -- cgit v1.2.3