Skip to content

Commit 8790ab1

Browse files
committed
rollup merge of #19310: steveklabnik/gh19178
Fixes #19178
2 parents 989d7a7 + 72beb1f commit 8790ab1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/doc/guide.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3997,6 +3997,22 @@ match origin {
39973997
}
39983998
```
39993999

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+
40004016
Whew! That's a lot of different ways to match things, and they can all be
40014017
mixed and matched, depending on what you're doing:
40024018

0 commit comments

Comments
 (0)