Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 14a6f29

Browse files
committedJun 4, 2024
Use inline const instead of unsafe to implement MaybeUninit::uninit_array().
1 parent a2c3406 commit 14a6f29

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed
 

‎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)
Failed to load comments.