summaryrefslogtreecommitdiffstats
path: root/src/doc/book/listings/ch18-patterns-and-matching/listing-18-14/src/main.rs
blob: b71da9a371784eb4c4cb845079852519d6f95ba1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
struct Point {
    x: i32,
    y: i32,
}

// ANCHOR: here
fn main() {
    let p = Point { x: 0, y: 7 };

    match p {
        Point { x, y: 0 } => println!("On the x axis at {x}"),
        Point { x: 0, y } => println!("On the y axis at {y}"),
        Point { x, y } => {
            println!("On neither axis: ({x}, {y})");
        }
    }
}
// ANCHOR_END: here