We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b7d7fc6 commit b33af51Copy full SHA for b33af51
library/core/src/array/mod.rs
@@ -18,7 +18,7 @@ use crate::ops::{
18
};
19
use crate::ptr::{null, null_mut};
20
use crate::random::{Random, RandomSource};
21
-use crate::slice::{self, Iter, IterMut};
+use crate::slice::{Iter, IterMut};
22
23
mod ascii;
24
mod drain;
@@ -455,12 +455,9 @@ macro_rules! impl_random_for_integer_array {
455
// SAFETY: all elements in the buffer were initialized with
456
// random bytes.
457
unsafe {
458
- let bytes = slice::from_raw_parts_mut(
459
- &raw mut buf as *mut u8,
460
- N * (<$t>::BITS as usize / 8),
461
- );
+ let bytes = buf.as_bytes_mut().assume_init_mut();
462
source.fill_bytes(bytes);
463
- mem::transmute_copy(&buf)
+ MaybeUninit::array_assume_init(buf)
464
}
465
466
0 commit comments