summaryrefslogtreecommitdiff
path: root/crates/utils/src
diff options
context:
space:
mode:
authorNathan Ringo <nathan@remexre.com>2024-08-31 23:30:46 -0500
committerNathan Ringo <nathan@remexre.com>2024-08-31 23:32:37 -0500
commit439b93dd3e22311caee6d69eb4aa1da5b81a0731 (patch)
treefdc2693067c82c032c8de04b62acbe99806883cd /crates/utils/src
parente9a79a0ed79609c1e293c7b221fce577200b2eb7 (diff)
Almost all of buddy initialization.
Diffstat (limited to 'crates/utils/src')
-rw-r--r--crates/utils/src/pin.rs7
1 files changed, 5 insertions, 2 deletions
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<T>(slice: Pin<&mut [T]>) -> impl Iterator<Item = Pin<&mut T>> {
- let base_ptr: NonNull<T> = NonNull::from(slice.as_ref().get_ref()).cast();
+pub fn pin_project_slice_mut_iter<T>(
+ mut slice: Pin<&mut [T]>,
+) -> impl Iterator<Item = Pin<&mut T>> {
+ // SAFETY: We never move out of this pointer.
+ let base_ptr: NonNull<T> = 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