How to print structs in Rust

1 Answer

0 votes
#[derive(Debug)]

struct Point{
    x: i32,
    y: i32
}

fn main() {
    let p = Point{ x: 13, y: 26 };
    
    println!("{:?}", p);
    println!("{:?}", p.x);
    println!("{:?}", p.y);
}



/*
run:

Point { x: 13, y: 26 }
13
26

*/

 



answered May 3, 2023 by avibootz
...