about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJonathan Turner <jonathandturner@users.noreply.github.com>2016-08-08 13:25:57 -0700
committerGitHub <noreply@github.com>2016-08-08 13:25:57 -0700
commit39a26c59ef976316cb564a77cdfa1a5ee3bff8ef (patch)
treedf77b9d7dccf268dde7bd075a0b571ebd79ef06b /src
parent732e8f204a6b81b06353f6c4826e3d5f774d3595 (diff)
parent18565c63db1982b927b291b9597368efc615d91c (diff)
downloadrust-39a26c59ef976316cb564a77cdfa1a5ee3bff8ef.tar.gz
rust-39a26c59ef976316cb564a77cdfa1a5ee3bff8ef.zip
Rollup merge of #35465 - cardoe:pattern-book-update, r=steveklabnik
book: update example patterns to be more clear

When using Point { x: 0, y: 0 } and showing pattern matching decomposing
x and y individually its hard to understand. By using a different value
for x and a different value for y it is more clear.
Diffstat (limited to 'src')
-rw-r--r--src/doc/book/patterns.md12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/doc/book/patterns.md b/src/doc/book/patterns.md
index a0245d4c7b1..910b1375476 100644
--- a/src/doc/book/patterns.md
+++ b/src/doc/book/patterns.md
@@ -109,14 +109,14 @@ struct Point {
     y: i32,
 }
 
-let origin = Point { x: 0, y: 0 };
+let point = Point { x: 2, y: 3 };
 
-match origin {
+match point {
     Point { x, .. } => println!("x is {}", x),
 }
 ```
 
-This prints `x is 0`.
+This prints `x is 2`.
 
 You can do this kind of match on any member, not only the first:
 
@@ -126,14 +126,14 @@ struct Point {
     y: i32,
 }
 
-let origin = Point { x: 0, y: 0 };
+let point = Point { x: 2, y: 3 };
 
-match origin {
+match point {
     Point { y, .. } => println!("y is {}", y),
 }
 ```
 
-This prints `y is 0`.
+This prints `y is 3`.
 
 This ‘destructuring’ behavior works on any compound data type, like
 [tuples][tuples] or [enums][enums].