Skip to content

Commit 80d776e

Browse files
committed
Change to use array::from_fn
1 parent f1580f3 commit 80d776e

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

Diff for: library/core/src/array/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,7 @@ impl<T: Clone, const N: usize> Clone for [T; N] {
430430
#[unstable(feature = "random", issue = "130703")]
431431
impl<T: Random, const N: usize> Random for [T; N] {
432432
fn random(source: &mut (impl RandomSource + ?Sized)) -> Self {
433-
let mut buf = [const { MaybeUninit::uninit() }; N];
434-
for elem in &mut buf {
435-
elem.write(T::random(source));
436-
}
437-
// SAFETY: all elements of the array were initialized.
438-
unsafe { mem::transmute_copy(&buf) }
433+
from_fn(|_| T::random(source))
439434
}
440435
}
441436

0 commit comments

Comments
 (0)