diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2017-02-12 19:16:34 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-12 19:16:34 +0100 |
| commit | 2f3dc95778861b26c80e99cfc1d7147f047974eb (patch) | |
| tree | bbda1dd0521dc5015f05037de674d5bb312b598f | |
| parent | fd006ad5a5428e0c944f2af6f7d9f92d80b4e226 (diff) | |
| parent | 037ef0bbc88742187e6059a846f027bb99884267 (diff) | |
| download | rust-2f3dc95778861b26c80e99cfc1d7147f047974eb.tar.gz rust-2f3dc95778861b26c80e99cfc1d7147f047974eb.zip | |
Rollup merge of #39760 - shepmaster:struct-init-doc, r=GuillaumeGomez
Improve grammar on field init docs
| -rw-r--r-- | src/doc/book/structs.md | 4 | ||||
| -rw-r--r-- | src/doc/reference.md | 8 |
2 files changed, 4 insertions, 8 deletions
diff --git a/src/doc/book/structs.md b/src/doc/book/structs.md index dcf74cbb0a7..f10fb6274c6 100644 --- a/src/doc/book/structs.md +++ b/src/doc/book/structs.md @@ -117,8 +117,8 @@ fn main() { } ``` -Initialization of a data structure (struct, enum, union) can be simplified if -fields of the data structure are initialized with variables which has same +Initialization of a data structure (struct, enum, union) can be simplified when +fields of the data structure are initialized with variables of the same names as the fields. ``` diff --git a/src/doc/reference.md b/src/doc/reference.md index 8aefabe61fd..ab4da862033 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2819,12 +2819,8 @@ Point3d {y: 0, z: 10, .. base}; #### Struct field init shorthand When initializing a data structure (struct, enum, union) with named fields, -allow writing `fieldname` as a shorthand for `fieldname: fieldname`. This -allows a compact syntax for initialization, with less duplication. - -In the initializer for a `struct` with named fields, a `union` with named -fields, or an enum variant with named fields, accept an identifier `field` as a -shorthand for `field: field`. +it is allowed to write `fieldname` as a shorthand for `fieldname: fieldname`. +This allows a compact syntax with less duplication. Example: |
