Commit 1632165
authored
Rollup merge of rust-lang#125995 - kpreid:const-uninit-stable, r=Nilstrieb
Use inline const blocks to create arrays of `MaybeUninit`.
This PR contains 2 changes enabled by the fact that [`inline_const` is now stable](rust-lang#104087), and was split out of rust-lang#125082.
1. Use inline const instead of `unsafe` to construct arrays in `MaybeUninit` examples.
Rationale: Demonstrate good practice of avoiding `unsafe` code where it is not strictly necessary.
4. Use inline const instead of `unsafe` to implement `MaybeUninit::uninit_array()`.
This is arguably giving the compiler more work to do, in exchange for eliminating just one single internal unsafe block, so it's less certain that this is good on net.
r? `@Nilstrieb`1 file changed
+5
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
| 123 | + | |
| 124 | + | |
129 | 125 | | |
130 | 126 | | |
131 | 127 | | |
| |||
147 | 143 | | |
148 | 144 | | |
149 | 145 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
| 146 | + | |
| 147 | + | |
154 | 148 | | |
155 | 149 | | |
156 | 150 | | |
| |||
348 | 342 | | |
349 | 343 | | |
350 | 344 | | |
351 | | - | |
352 | | - | |
| 345 | + | |
353 | 346 | | |
354 | 347 | | |
355 | 348 | | |
| |||
0 commit comments