trpl-zh-cn/listings/ch18-patterns-and-matching/listing-18-23/src/main.rs

16 lines
252 B
Rust
Raw Normal View History

2022-02-06 16:43:51 +08:00
fn main() {
// ANCHOR: here
struct Point {
x: i32,
y: i32,
z: i32,
}
let origin = Point { x: 0, y: 0, z: 0 };
match origin {
Point { x, .. } => println!("x is {x}"),
2022-02-06 16:43:51 +08:00
}
// ANCHOR_END: here
}