about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/doc/book/structs.md6
-rw-r--r--src/doc/reference.md9
2 files changed, 10 insertions, 5 deletions
diff --git a/src/doc/book/structs.md b/src/doc/book/structs.md
index 811f7b41967..dcf74cbb0a7 100644
--- a/src/doc/book/structs.md
+++ b/src/doc/book/structs.md
@@ -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)]
diff --git a/src/doc/reference.md b/src/doc/reference.md
index 6f2ce5fd8d1..8139a712bdd 100644
--- a/src/doc/reference.md
+++ b/src/doc/reference.md
@@ -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