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/expressions/struct-expr.md
+5-4
Original file line number
Diff line number
Diff line change
@@ -27,8 +27,8 @@
27
27
>
28
28
> _StructExprUnit_ : [_PathInExpression_]
29
29
30
-
A _struct expression_ creates a struct or union value.
31
-
It consists of a path to a [struct] or [union] item followed by the values for the fields of the item.
30
+
A *struct expression* creates a struct, enum, or union value.
31
+
It consists of a path to a [struct], [enum variant], or [union] item followed by the values for the fields of the item.
32
32
There are three forms of struct expressions: struct, tuple, and unit.
33
33
34
34
The following are examples of struct expressions:
@@ -52,11 +52,11 @@ some_fn::<Cookie>(Cookie);
52
52
A struct expression with fields enclosed in curly braces allows you to specify the value for each individual field in any order.
53
53
The field name is separated from its value with a colon.
54
54
55
-
A value of a [union] type can also be created using this syntax, except that it must specify exactly one field.
55
+
A value of a [union] type can only be created using this syntax, and it must specify exactly one field.
56
56
57
57
## Functional update syntax
58
58
59
-
A struct expression can terminate with the syntax `..` followed by an expression to denote a functional update.
59
+
A struct expression that constructs a value of a struct type can terminate with the syntax `..` followed by an expression to denote a functional update.
60
60
The expression following `..` (the base) must have the same struct type as the new struct type being formed.
61
61
62
62
The entire expression uses the given values for the fields that were specified and moves or copies the remaining fields from the base expression.
@@ -134,6 +134,7 @@ let b = Gamma{}; // Exact same value as `a`.
0 commit comments