Skip to content

Commit b33af51

Browse files
committed
Apply suggestions from code review
1 parent b7d7fc6 commit b33af51

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

library/core/src/array/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::ops::{
1818
};
1919
use crate::ptr::{null, null_mut};
2020
use crate::random::{Random, RandomSource};
21-
use crate::slice::{self, Iter, IterMut};
21+
use crate::slice::{Iter, IterMut};
2222

2323
mod ascii;
2424
mod drain;
@@ -455,12 +455,9 @@ macro_rules! impl_random_for_integer_array {
455455
// SAFETY: all elements in the buffer were initialized with
456456
// random bytes.
457457
unsafe {
458-
let bytes = slice::from_raw_parts_mut(
459-
&raw mut buf as *mut u8,
460-
N * (<$t>::BITS as usize / 8),
461-
);
458+
let bytes = buf.as_bytes_mut().assume_init_mut();
462459
source.fill_bytes(bytes);
463-
mem::transmute_copy(&buf)
460+
MaybeUninit::array_assume_init(buf)
464461
}
465462
}
466463
}

0 commit comments

Comments
 (0)