Skip to content

Commit b9558f0

Browse files
committed
limit unsafe scope
1 parent 3348530 commit b9558f0

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/vec/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -377,17 +377,17 @@ impl<T, LenT: LenType, const N: usize> Vec<T, N, LenT> {
377377
}
378378
} else {
379379
let mut v = Self::new();
380-
unsafe {
381-
// MaybeUninit::deref is non-const, so we just cast it through.
382-
// Casting to internal value of MaybeUninit<T> is safe since it is transparent.
383-
let src_ptr: *const T = ptr::from_ref(&src).cast();
384380

385-
// Cast from [MaybeUninit] to [T] is safe since it is transparent.
386-
let dst_ptr: *mut T = v.buffer.buffer.as_mut_ptr().cast();
381+
// MaybeUninit::deref is non-const, so we just cast it through.
382+
// Casting to internal value of MaybeUninit<T> is safe since it is transparent.
383+
let src_ptr: *const T = ptr::from_ref(&src).cast();
384+
385+
// Cast from [MaybeUninit] to [T] is safe since it is transparent.
386+
let dst_ptr: *mut T = v.buffer.buffer.as_mut_ptr().cast();
387+
388+
unsafe { ptr::copy_nonoverlapping(src_ptr, dst_ptr, M) };
389+
v.len = len;
387390

388-
ptr::copy_nonoverlapping(src_ptr, dst_ptr, M);
389-
v.len = len;
390-
}
391391
v
392392
}
393393
}

0 commit comments

Comments
 (0)