Skip to content

Commit

Permalink
Small improvements to the example
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Clarke committed Apr 18, 2019
1 parent 3104870 commit aaddc14
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ fn main() {
let foo = Foo { x: (1, 2), y: 3 };
match foo {
Foo { x: (1, b), y } => println!("a = 1, b = {}, y = {} ", b, y),
Foo { x: (1, b), y } => println!("First of x is 1, b = {}, y = {} ", b, y),
// you can destructure structs and rename the variables,
// the order is not important
Foo { y: 2, x: i } => println!("i = {:?}, j = 2", i),
Foo { y: 2, x: i } => println!("y is 2, i = {:?}", i),
// and you can also ignore some variables:
Foo { y, .. } => println!("y = {}", y),
Foo { y, .. } => println!("y = {}, we don't care about x", y),
// this will give an error: pattern does not mention field `x`
//Foo { y } => println!("y = {}", y);
}
Expand Down

0 comments on commit aaddc14

Please sign in to comment.