字段和属性

结构体(记录)

#[derive(Debug)]
#[allow(dead_code)]
struct ColorPoint {
    //字段
    x: i32,
    y: i32,
    //Rust 中没有属性
    color: String
}

let p = ColorPoint{
    x: 1, y: 2, 
    color: "red".to_string()};

println!("p is '{:?}'", p);