Skip to content

Commit 9a1153b

Browse files
rcseacordmanhatsu
authored andcommitted
Update types-and-traits.rst
1 parent 39962d6 commit 9a1153b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/coding-guidelines/types-and-traits/gui_UnionFieldValidity.rst.inc

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
Unions allow multiple fields to occupy the same memory, similar to C unions.
3030
Unlike enumeration types, unions do not track which field is currently active.
3131
You must ensure that when a field is read,
32-
the underlying bytes are valid for that field's type [UNION]_.
32+
the underlying bytes are valid for that field's type [RUST-REF-UNION]_.
3333
3434
Every type has a *validity invariant* — a set of constraints that all values of
35-
that type must satisfy [VALID]_.
35+
that type must satisfy [UCG-VALIDITY]_.
3636
Reading a union field performs a *typed read*,
3737
which asserts that the bytes are valid for the target type.
3838
@@ -280,11 +280,17 @@
280280

281281
.. list-table::
282282
:header-rows: 0
283-
:widths: 5 60
284-
285-
* - .. [UNION]
286-
- The Rust Project Developers. "Rust Reference: Unions." *The Rust Reference*, n.d. https://doc.rust-lang.org/reference/items/unions.html.
287-
* - .. [VALID]
288-
- Rust Unsafe Code Guidelines Working Group. "Validity and Safety Invariant." *Rust Unsafe Code Guidelines*, n.d. https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#validity-and-safety-invariant.
283+
:widths: 10 90
284+
:class: bibliography-table
285+
286+
* - .. [RUST-REF-UNION]
287+
- The Rust Project Developers. "Rust Reference: Unions."
288+
*The Rust Reference*, n.d.
289+
https://doc.rust-lang.org/reference/items/unions.html.
290+
291+
* - .. [UCG-VALIDITY]
292+
- Rust Unsafe Code Guidelines Working Group. "Validity and Safety
293+
Invariant." *Rust Unsafe Code Guidelines*, n.d.
294+
https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#validity-and-safety-invariant.
289295

290296
>>>>>>> c93b2cb (Update types-and-traits.rst):src/coding-guidelines/types-and-traits.rst

0 commit comments

Comments
 (0)