Skip to content

Commit ec8fa17

Browse files
committed
Use inline const instead of unsafe to implement MaybeUninit::uninit_array().
1 parent ac96fa4 commit ec8fa17

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

library/core/src/mem/maybe_uninit.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ impl<T> MaybeUninit<T> {
342342
#[must_use]
343343
#[inline(always)]
344344
pub const fn uninit_array<const N: usize>() -> [Self; N] {
345-
// SAFETY: An uninitialized `[MaybeUninit<_>; LEN]` is valid.
346-
unsafe { MaybeUninit::<[MaybeUninit<T>; N]>::uninit().assume_init() }
345+
[const { MaybeUninit::uninit() }; N]
347346
}
348347

349348
/// Creates a new `MaybeUninit<T>` in an uninitialized state, with the memory being

0 commit comments

Comments
 (0)