Skip to content

Commit

Permalink
Extra note about struct matching order
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed Nov 25, 2014
1 parent 48ca6d1 commit 72beb1f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/doc/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -3991,6 +3991,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:

Expand Down

1 comment on commit 72beb1f

@alexcrichton
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+

Please sign in to comment.