File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -30,21 +30,21 @@ let u = MyUnion { f1: 1 };
30
30
```
31
31
32
32
The expression above creates a value of type ` MyUnion ` and initializes the
33
- storage using field ` f1 ` . The union can be accessed using the same syntax as
33
+ storage using field ` f1 ` . The union can be accessed using the same syntax as
34
34
struct fields:
35
35
36
36
``` rust,ignore
37
37
let f = u.f1;
38
38
```
39
39
40
- Unions have no notion of an "active field". Instead, every union access just
41
- interprets the storage at the type of the field used for the access. Reading a
40
+ Unions have no notion of an "active field". Instead, every union access just
41
+ interprets the storage at the type of the field used for the access. Reading a
42
42
union field is equivalent to a [ ` transmute ` ] : The data in the union, no matter
43
- how it was stored there, is transmuted to the type of the field. Just like with
43
+ how it was stored there, is transmuted to the type of the field Just like with
44
44
any other transmute, it is the programmer's responsibility to make sure that the
45
- data is valid for the field type. Failing to do so results in undefined
45
+ data is valid for the field type. Failing to do so results in undefined
46
46
behavior (for example, reading the value ` 3 ` at type ` bool ` is undefined
47
- behavior). For this reason, all reads of union fields have to be placed in
47
+ behavior). For this reason, all reads of union fields have to be placed in
48
48
` unsafe ` blocks:
49
49
50
50
``` rust
You can’t perform that action at this time.
0 commit comments