Skip to content

Commit 96e138f

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

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ Types and Traits
5959
:id: non_compl_ex_UnionBool
6060
:status: draft
6161

62-
This noncompliant example reads a Boolean from a union field containing an invalid bit pattern.
63-
The value ``3`` is not a valid Boolean (only ``0`` and ``1`` are valid).
62+
This noncompliant example reads an invalid bit pattern from a Boolean union field.
63+
The value ``3`` is not a valid value of type ``bool`` (only ``0`` and ``1`` are valid).
6464

6565
.. code-block:: rust
6666
@@ -80,7 +80,7 @@ Types and Traits
8080
:id: non_compl_ex_UnionChar
8181
:status: draft
8282

83-
This noncompliant example reads a ``char`` from a ``union`` containing an invalid Unicode value.
83+
This noncompliant example reads an invalid Unicode value from a ``union`` field of type ``char`` .
8484

8585
.. code-block:: rust
8686
@@ -129,7 +129,8 @@ Types and Traits
129129
:id: non_compl_ex_UnionRef
130130
:status: draft
131131

132-
This noncompliant example reads a reference from a ``union`` containing a null or misaligned pointer.
132+
This noncompliant example reads a reference from a ``union`` containing a null pointer.
133+
A similar problem occurs when reading a misaligned pointer.
133134

134135
.. code-block:: rust
135136
@@ -141,8 +142,8 @@ Types and Traits
141142
fn main() {
142143
let u = PtrOrRef { p: std::ptr::null() };
143144
144-
// Non-compliant: null is not a valid reference
145-
let invalid_ref = unsafe { u.r }; // UB: references cannot be null
145+
// Undefined behavior reading a null value from a reference field of a union
146+
unsafe { u.r }; // Noncompliant
146147
}
147148
148149
.. compliant_example::
@@ -204,7 +205,7 @@ Types and Traits
204205
:id: compl_ex_UnionSameField
205206
:status: draft
206207

207-
This compliant solution read from the same field that was written.
208+
This compliant solution reads from the same field that was written.
208209

209210
.. code-block:: rust
210211

0 commit comments

Comments
 (0)