diff options
| author | Kevin Reid <kpreid@switchb.org> | 2024-05-12 21:36:09 -0700 |
|---|---|---|
| committer | Kevin Reid <kpreid@switchb.org> | 2024-06-04 14:40:22 -0700 |
| commit | ec8fa177190f1f0279fade487dfa4cef23dd1101 (patch) | |
| tree | 0a533567b11ed778ef5c7080291114411b7ea8c7 | |
| parent | ac96fa44faa786ad5682e6ed7359842d0e6a4b53 (diff) | |
| download | rust-ec8fa177190f1f0279fade487dfa4cef23dd1101.tar.gz rust-ec8fa177190f1f0279fade487dfa4cef23dd1101.zip | |
Use inline const instead of unsafe to implement `MaybeUninit::uninit_array()`.
| -rw-r--r-- | library/core/src/mem/maybe_uninit.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 56af7fa9c89..4175d4a3329 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -342,8 +342,7 @@ impl<T> MaybeUninit<T> { #[must_use] #[inline(always)] pub const fn uninit_array<const N: usize>() -> [Self; N] { - // SAFETY: An uninitialized `[MaybeUninit<_>; LEN]` is valid. - unsafe { MaybeUninit::<[MaybeUninit<T>; N]>::uninit().assume_init() } + [const { MaybeUninit::uninit() }; N] } /// Creates a new `MaybeUninit<T>` in an uninitialized state, with the memory being |
