@@ -89,7 +89,8 @@ let c3 = Color{1: 0, ..c2}; // Fill out all other fields using a base struct.
89
89
90
90
When initializing a data structure (struct, enum, union) with named (but not
91
91
numbered) fields, it is allowed to write ` fieldname ` as a shorthand for
92
- ` fieldname: fieldname ` . This allows a compact syntax with less duplication. Example:
92
+ ` fieldname: fieldname ` . This allows a compact syntax with less duplication.
93
+ For example:
93
94
94
95
``` rust
95
96
# struct Point3d { x : i32 , y : i32 , z : i32 }
@@ -104,7 +105,7 @@ Point3d { x, y: y_value, z };
104
105
105
106
A struct expression with fields enclosed in parentheses constructs a tuple struct. Though
106
107
it is listed here as a specific expression for completeness, it is equivalent to a [ call
107
- expression] to the tuple struct's constructor. Example :
108
+ expression] to the tuple struct's constructor. For example :
108
109
109
110
``` rust
110
111
struct Position (i32 , i32 , i32 );
@@ -117,7 +118,7 @@ let pos = c(8, 6, 7); // Creates a `Position` value.
117
118
118
119
A unit struct expression is just the path to a unit struct item. This refers to the unit
119
120
struct's implicit constant of its value. The unit struct value can also be constructed
120
- with fieldless struct expression. Example :
121
+ with a fieldless struct expression. For example :
121
122
122
123
``` rust
123
124
struct Gamma ;
0 commit comments