Wartości domyślne struktury rdzy

struct Point {
    x: i32,
    y: i32
}

impl Default for Point {
    fn default() -> Point {
        Point {
            x: 0,
            y: 1
        }
    }
}

fn main() {
    // initialize a default point
    let p1 = Point { ..Default::default() };

    // initialize a point with default value for all fields except 
    // y that is set to 0
    let p2 = Point { y: 0, ..Default::default() };
    
    println!("{}, {}", p1.x, p1.y); // 0, 1
    println!("{}, {}", p2.x, p2.y); // 0, 0
	
}
PeruTilli