Skip to content

Commit 30b4026

Browse files
authored
Update types-and-traits.rst
1 parent d0a45a0 commit 30b4026

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ Types and Traits
3737
Unions allow multiple fields to occupy the same memory, similar to C unions.
3838
Unlike enumeration types, unions do not track which field is currently active.
3939
You must ensure that when a field is read,
40-
the underlying bytes are valid for that field's type [UNION]_.
40+
the underlying bytes are valid for that field's type [RUST-REF-UNION]_.
4141

4242
Every type has a *validity invariant* — a set of constraints that all values of
43-
that type must satisfy [VALID]_.
43+
that type must satisfy [UCG-VALIDITY]_.
4444
Reading a union field performs a *typed read*,
4545
which asserts that the bytes are valid for the target type.
4646

@@ -288,12 +288,18 @@ Types and Traits
288288

289289
.. list-table::
290290
:header-rows: 0
291-
:widths: 5 60
292-
293-
* - .. [UNION]
294-
- The Rust Project Developers. "Rust Reference: Unions." *The Rust Reference*, n.d. https://doc.rust-lang.org/reference/items/unions.html.
295-
* - .. [VALID]
296-
- 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.
291+
:widths: 10 90
292+
:class: bibliography-table
293+
294+
* - .. [RUST-REF-UNION]
295+
- The Rust Project Developers. "Rust Reference: Unions."
296+
*The Rust Reference*, n.d.
297+
https://doc.rust-lang.org/reference/items/unions.html.
298+
299+
* - .. [UCG-VALIDITY]
300+
- Rust Unsafe Code Guidelines Working Group. "Validity and Safety
301+
Invariant." *Rust Unsafe Code Guidelines*, n.d.
302+
https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#validity-and-safety-invariant.
297303

298304
.. guideline:: Use strong types to differentiate between logically distinct values
299305
:id: gui_xztNdXA2oFNC

0 commit comments

Comments
 (0)