]> git.lizzy.rs Git - rust.git/blobdiff - src/doc/guide.md
rollup merge of #19310: steveklabnik/gh19178
[rust.git] / 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: