We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 989d7a7 + 72beb1f commit 8790ab1Copy full SHA for 8790ab1
src/doc/guide.md
@@ -3997,6 +3997,22 @@ match origin {
3997
}
3998
```
3999
4000
+You can do this kind of match on any member, not just the first:
4001
+
4002
+```{rust}
4003
+# #![allow(non_shorthand_field_patterns)]
4004
+struct Point {
4005
+ x: int,
4006
+ y: int,
4007
+}
4008
4009
+let origin = Point { x: 0i, y: 0i };
4010
4011
+match origin {
4012
+ Point { y: y, .. } => println!("y is {}", y),
4013
4014
+```
4015
4016
Whew! That's a lot of different ways to match things, and they can all be
4017
mixed and matched, depending on what you're doing:
4018
0 commit comments