diff options
| author | Son <leson.phung@gmail.com> | 2017-02-02 22:24:50 +1100 |
|---|---|---|
| committer | Son <leson.phung@gmail.com> | 2017-02-02 22:24:50 +1100 |
| commit | c4cd4e19d976240443ef31968e7b763cf83d6fdb (patch) | |
| tree | aeddfc860eb2188570c1cd33e83f03d1d8f3879a /src | |
| parent | a7b65f15781e479d6d0cd98f0865cc3ec0dc03ac (diff) | |
| download | rust-c4cd4e19d976240443ef31968e7b763cf83d6fdb.tar.gz rust-c4cd4e19d976240443ef31968e7b763cf83d6fdb.zip | |
Wrap 80 columns
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc/book/structs.md | 6 | ||||
| -rw-r--r-- | src/doc/reference.md | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/doc/book/structs.md b/src/doc/book/structs.md index 5a13746d0a8..811f7b41967 100644 --- a/src/doc/book/structs.md +++ b/src/doc/book/structs.md @@ -117,7 +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: +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: ``` #![feature(field_init_shorthand)] @@ -133,7 +135,7 @@ fn main() { let name = "Peter"; let age = 27; let peter = Person { name, age }; - + // Print debug struct println!("{:?}", peter); } diff --git a/src/doc/reference.md b/src/doc/reference.md index 32e0f9bbed8..6f2ce5fd8d1 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2759,9 +2759,13 @@ 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. +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`. +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`. Example: |
