Closed
Description
In the patterns part of the guide, all the examples do matches forward. There should be examples with a different order to show the order isn't important:
struct Point { x: int, y: int, z: int, w: int}
let origin = Point { x: 0, y: 0, z: 0, w: 0};
// All examples do this
match origin {
Point { x, .. } => println!("x is {}", x),
}
// If you only want the last value...this doesn't work
match origin {
Point { ..,w } => println!("w is {}", w),
}
// Indicate that the order is irrelevant
match origin {
Point { w, y, z, x } => println!("y is {}, w is {}", y, w),
}
// Then you can do this
match origin {
Point { w, .. } => println!("w is {}", w),
}
Metadata
Metadata
Assignees
Labels
No labels