「Rust」構造体structのサンプル

書式
struct Color(u8, u8, u8);
struct Point(f64, f64);
使用例

 fn main() {
    struct Color(u8, u8, u8);
    struct Point(f64, f64);

    let black = Color(0, 0, 0);
    let origin = Point(0.0, 0.0);

    println!("black = ({}, {}, {})", black.0, black.1, black.2);
    println!("origin = ({}, {})", origin.0, origin.1);
}

結果
black = (0, 0, 0)
origin = (0, 0)

Rust

Posted by arkgame