]> git.lizzy.rs Git - rust.git/commitdiff
rollup merge of #19310: steveklabnik/gh19178
authorAlex Crichton <alex@alexcrichton.com>
Wed, 26 Nov 2014 17:44:57 +0000 (09:44 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 27 Nov 2014 00:49:49 +0000 (16:49 -0800)
Fixes #19178

src/doc/guide.md

index c3fdb7c2625361a7e2324961b358fe2d86f8fd50..4387ff7ccfc5bb8aa2e95c6f23ac2d49c549bbf6 100644 (file)
@@ -3997,6 +3997,22 @@ match origin {
 }
 ```
 
+You can do this kind of match on any member, not just the first:
+
+```{rust}
+# #![allow(non_shorthand_field_patterns)]
+struct Point {
+    x: int,
+    y: int,
+}
+
+let origin = Point { x: 0i, y: 0i };
+
+match origin {
+    Point { y: y, .. } => println!("y is {}", y),
+}
+```
+
 Whew! That's a lot of different ways to match things, and they can all be
 mixed and matched, depending on what you're doing: