|
30 | 30 | Similar to C, unions allow multiple fields to occupy the same memory. |
31 | 31 | Unlike enumeration types, unions do not track which field is currently active. |
32 | 32 | You must ensure that when a field is read that |
33 | | - the underlying bytes are valid for that field's type [RUST-REF-UNION]_. |
| 33 | + the underlying bytes are valid for that field's type :cite:`gui_0cuTYG8RVYjg:RUST-REF-UNION`. |
34 | 34 |
|
35 | 35 | Every type has a *validity invariant* — a set of constraints that all values of |
36 | | - that type must satisfy [UCG-VALIDITY]_. |
| 36 | + that type must satisfy :cite:`gui_0cuTYG8RVYjg:UCG-VALIDITY`. |
37 | 37 | Reading a union field performs a *typed read*, |
38 | 38 | which asserts that the bytes are valid for the target type. |
39 | 39 |
|
|
274 | 274 | } |
275 | 275 |
|
276 | 276 | .. bibliography:: |
277 | | - :id: bib_UnionFieldValidity |
| 277 | + :id: bib_WNCi5njUWLuZ |
278 | 278 | :status: draft |
279 | 279 |
|
280 | 280 | .. list-table:: |
281 | 281 | :header-rows: 0 |
282 | 282 | :widths: auto |
283 | 283 | :class: bibliography-table |
284 | 284 |
|
285 | | - * - .. [RUST-REF-UNION] |
286 | | - - | The Rust Project Developers. "Rust Reference: Unions." |
287 | | - | *The Rust Reference*, n.d. |
288 | | - | https://doc.rust-lang.org/reference/items/unions.html. |
| 285 | + * - :bibentry:`gui_0cuTYG8RVYjg:RUST-REF-UNION` |
| 286 | + - The Rust Reference. "Unions." https://doc.rust-lang.org/reference/items/unions.html. |
289 | 287 |
|
290 | | - * - .. [UCG-VALIDITY] |
291 | | - - | Rust Unsafe Code Guidelines Working Group. "Validity and Safety Invariant." |
292 | | - | *Rust Unsafe Code Guidelines*, n.d. |
293 | | - | https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#validity-and-safety-invariant. |
| 288 | + * - :bibentry:`gui_0cuTYG8RVYjg:UCG-VALIDITY` |
| 289 | + - Rust Unsafe Code Guidelines. "Validity and Safety Invariant." https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#validity-and-safety-invariant. |
294 | 290 |
|
0 commit comments