Skip to content

Commit e366e17

Browse files
committed
Address comments
1 parent 23c6602 commit e366e17

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/lib.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@ macro_rules! arbitrary_tuple {
571571
}
572572
arbitrary_tuple!(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z);
573573

574+
// Helper to safely create arrays since the standard library doesn't
575+
// provide one yet. Shouldn't be necessary in the future.
574576
struct ArrayGuard<T, const N: usize> {
575577
dst: *mut T,
576578
initialized: usize,
@@ -591,9 +593,11 @@ where
591593
F: FnMut(usize) -> T,
592594
{
593595
let mut array: mem::MaybeUninit<[T; N]> = mem::MaybeUninit::uninit();
596+
let array_ptr = array.as_mut_ptr();
597+
let dst = array_ptr as _;
594598
let mut guard: ArrayGuard<T, N> = ArrayGuard {
595-
dst: array.as_mut_ptr() as _,
596-
initialized: 0,
599+
dst,
600+
initialized: 0
597601
};
598602
unsafe {
599603
for (idx, value_ptr) in (&mut *array.as_mut_ptr()).iter_mut().enumerate() {
@@ -610,9 +614,11 @@ where
610614
F: FnMut(usize) -> Result<T>,
611615
{
612616
let mut array: mem::MaybeUninit<[T; N]> = mem::MaybeUninit::uninit();
617+
let array_ptr = array.as_mut_ptr();
618+
let dst = array_ptr as _;
613619
let mut guard: ArrayGuard<T, N> = ArrayGuard {
614-
dst: array.as_mut_ptr() as _,
615-
initialized: 0,
620+
dst,
621+
initialized: 0
616622
};
617623
unsafe {
618624
for (idx, value_ptr) in (&mut *array.as_mut_ptr()).iter_mut().enumerate() {

0 commit comments

Comments
 (0)