Skip to content

Commit 037ef0b

Browse files
committed
Improve grammar on field init docs
1 parent ba7cf7c commit 037ef0b

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

Diff for: src/doc/book/structs.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ fn main() {
117117
}
118118
```
119119

120-
Initialization of a data structure (struct, enum, union) can be simplified if
121-
fields of the data structure are initialized with variables which has same
120+
Initialization of a data structure (struct, enum, union) can be simplified when
121+
fields of the data structure are initialized with variables of the same
122122
names as the fields.
123123

124124
```

Diff for: src/doc/reference.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -2819,12 +2819,8 @@ Point3d {y: 0, z: 10, .. base};
28192819
#### Struct field init shorthand
28202820

28212821
When initializing a data structure (struct, enum, union) with named fields,
2822-
allow writing `fieldname` as a shorthand for `fieldname: fieldname`. This
2823-
allows a compact syntax for initialization, with less duplication.
2824-
2825-
In the initializer for a `struct` with named fields, a `union` with named
2826-
fields, or an enum variant with named fields, accept an identifier `field` as a
2827-
shorthand for `field: field`.
2822+
it is allowed to write `fieldname` as a shorthand for `fieldname: fieldname`.
2823+
This allows a compact syntax with less duplication.
28282824

28292825
Example:
28302826

0 commit comments

Comments
 (0)