@@ -120,12 +120,8 @@ use crate::slice;
120
120
/// use std::mem::{self, MaybeUninit};
121
121
///
122
122
/// let data = {
123
- /// // Create an uninitialized array of `MaybeUninit`. The `assume_init` is
124
- /// // safe because the type we are claiming to have initialized here is a
125
- /// // bunch of `MaybeUninit`s, which do not require initialization.
126
- /// let mut data: [MaybeUninit<Vec<u32>>; 1000] = unsafe {
127
- /// MaybeUninit::uninit().assume_init()
128
- /// };
123
+ /// // Create an uninitialized array of `MaybeUninit`.
124
+ /// let mut data: [MaybeUninit<Vec<u32>>; 1000] = [const { MaybeUninit::uninit() }; 1000];
129
125
///
130
126
/// // Dropping a `MaybeUninit` does nothing, so if there is a panic during this loop,
131
127
/// // we have a memory leak, but there is no memory safety issue.
@@ -147,10 +143,8 @@ use crate::slice;
147
143
/// ```
148
144
/// use std::mem::MaybeUninit;
149
145
///
150
- /// // Create an uninitialized array of `MaybeUninit`. The `assume_init` is
151
- /// // safe because the type we are claiming to have initialized here is a
152
- /// // bunch of `MaybeUninit`s, which do not require initialization.
153
- /// let mut data: [MaybeUninit<String>; 1000] = unsafe { MaybeUninit::uninit().assume_init() };
146
+ /// // Create an uninitialized array of `MaybeUninit`.
147
+ /// let mut data: [MaybeUninit<String>; 1000] = [const { MaybeUninit::uninit() }; 1000];
154
148
/// // Count the number of elements we have assigned.
155
149
/// let mut data_len: usize = 0;
156
150
///
0 commit comments