Skip to content

Commit

Permalink
Simplify wording & fix test src/doc
Browse files Browse the repository at this point in the history
  • Loading branch information
phungleson committed Feb 3, 2017
1 parent c4cd4e1 commit 4ddb56b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/doc/book/structs.md
Expand Up @@ -117,9 +117,9 @@ fn main() {
}
```

We can initializing a data structure (struct, enum, union) with named fields,
by writing `fieldname` as a shorthand for `fieldname: fieldname`. This allows a
compact syntax for initialization, with less duplication:
Initialization of a data structure (struct, enum, union) can be simplified if
fields of the data structure are initialized with variables which has same
names as the fields.

```
#![feature(field_init_shorthand)]
Expand Down
9 changes: 7 additions & 2 deletions src/doc/reference.md
Expand Up @@ -2770,8 +2770,13 @@ shorthand for `field: field`.
Example:

```
let a = SomeStruct { field1, field2: expression, field3 };
let b = SomeStruct { field1: field1, field2: expression, field3: field3 };
# #![feature(field_init_shorthand)]
# struct Point3d { x: i32, y: i32, z: i32 }
# let x = 0;
# let y_value = 0;
# let z = 0;
Point3d { x: x, y: y_value, z: z };
Point3d { x, y: y_value, z };
```

### Block expressions
Expand Down

0 comments on commit 4ddb56b

Please sign in to comment.