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
+6-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], 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,7 +52,7 @@ 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
@@ -101,7 +101,8 @@ Point3d { x, y: y_value, z };
101
101
## Tuple struct expression
102
102
103
103
A struct expression with fields enclosed in parentheses constructs a tuple struct.
104
-
Though it is listed here as a specific expression for completeness, it is equivalent to a [call expression] to the tuple struct's constructor. For example:
104
+
Though it is listed here as a specific expression for completeness, it is equivalent to a [call expression] to the tuple struct's constructor. For example: <!--
105
+
This is false. Example: Position(0, ..other_position) -->
105
106
106
107
```rust
107
108
structPosition(i32, i32, i32);
@@ -134,6 +135,7 @@ let b = Gamma{}; // Exact same value as `a`.
0 commit comments