You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/types/struct.md
+10-7Lines changed: 10 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,10 +29,13 @@ A _unit-like struct_ type is like a struct type, except that it has no fields.
29
29
The one value constructed by the associated [struct expression] is the only
30
30
value that inhabits such a type.
31
31
32
-
## Struct and aggregate values
32
+
## Struct
33
33
34
34
r[type.struct.value]
35
35
36
+
r[type.struct.value.intro]
37
+
A value of a struct type consists of a list of values for each field.
38
+
36
39
r[type.struct.value.value-bytes]
37
40
A byte `b` in the representation of an aggregate is a value byte if there exists a field of that aggregate such that:
38
41
* The field has some type `T`,
@@ -45,15 +48,15 @@ A byte `b` in the representation of an aggregate is a value byte if there exists
45
48
r[type.struct.value.padding]
46
49
Every byte in an aggregate which is not a value byte is a padding byte.
47
50
48
-
r[type.struct.value.struct]
49
-
A value of a struct type consists of the values of each of its fields.
50
-
The representation of such a struct contains the representation of the value of each field at its corresponding offset.
51
+
> [!NOTE]
52
+
> Enum types can also have padding bytes.
51
53
52
-
r[type.struct.value.padding-uninit]
53
-
When a value of an aggregate is encoded, each padding byte is left as uninit
54
+
r[type.struct.value.encode-decode]
55
+
When a value of a struct type is encoded, each field of the struct is encoded at its corresponding offset and each byte that is not within a field of the struct is set to uninit.
56
+
When a value of a struct type is decoded, each field of the struct is decoded from its corresponding offset.
54
57
55
58
> [!NOTE]
56
-
> It is valid for padding bytes to hold a value other than uninit when decoded, and these bytes are ignored when decoding an aggregate.
59
+
> It is valid for padding bytes to hold a value other than uninit when decoded, and these bytes are ignored when decoding an struct value.
57
60
58
61
[^structtype]: `struct` types are analogous to `struct` types in C, the
59
62
*record* types of the ML family, or the *struct* types of the Lisp family.
0 commit comments