Skip to content

Commit dbd1a09

Browse files
authored
Reorder struct pattern examples (#2749)
I generally like to start with that second case since imo it's the simplest one before going on to the case that uses a tuple sub-pattern to break up the `x` field.
1 parent 77b201c commit dbd1a09

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

third_party/rust-by-example/destructuring-structs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ struct Foo {
77
fn main() {
88
let foo = Foo { x: (1, 2), y: 3 };
99
match foo {
10-
Foo { x: (1, b), y } => println!("x.0 = 1, b = {b}, y = {y}"),
1110
Foo { y: 2, x: i } => println!("y = 2, x = {i:?}"),
11+
Foo { x: (1, b), y } => println!("x.0 = 1, b = {b}, y = {y}"),
1212
Foo { y, .. } => println!("y = {y}, other fields were ignored"),
1313
}
1414
}

0 commit comments

Comments
 (0)