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
A struct expression with fields enclosed in parentheses constructs a tuple struct.
123
-
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:
124
+
A struct expression with fields enclosed in parentheses constructs a tuple struct or a tuple variant of an enum.
125
+
Though it is listed here as a specific expression for completeness, it is equivalent to a [call expression] to the tuple struct's (enum tuple variant's) constructor. For example:
124
126
125
127
```rust
126
128
structPosition(i32, i32, i32);
127
129
Position(0, 0, 0); // Typical way of creating a tuple struct.
128
130
letc=Position; // `c` is a function that takes 3 arguments.
129
131
letpos=c(8, 6, 7); // Creates a `Position` value.
132
+
133
+
enumVersion { Triple(i32, i32, i32) };
134
+
Version::Triple(0, 0, 0);
135
+
letf=Version::Triple;
136
+
letver=f(8, 6, 7);
130
137
```
131
138
132
139
> [!NOTE]
@@ -146,14 +153,18 @@ let pos = c(8, 6, 7); // Creates a `Position` value.
0 commit comments