1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-06-12 20:37:32 +02:00

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.
This commit is contained in:
Nicole L 2025-05-16 14:10:30 -07:00 committed by GitHub
parent 77b201c4cb
commit dbd1a09031
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,8 +7,8 @@ struct Foo {
fn main() {
let foo = Foo { x: (1, 2), y: 3 };
match foo {
Foo { x: (1, b), y } => println!("x.0 = 1, b = {b}, y = {y}"),
Foo { y: 2, x: i } => println!("y = 2, x = {i:?}"),
Foo { x: (1, b), y } => println!("x.0 = 1, b = {b}, y = {y}"),
Foo { y, .. } => println!("y = {y}, other fields were ignored"),
}
}