「Rust」構造体structの内容を出力するサンプル
書式
struct 構造体名
使用例
#[derive(Debug)]
struct Rectangle {
width: u32,
height: u32,
}
fn main() {
let rectA = Rectangle { width: 44, height: 88 };
println!("rectA is {:?}", rectA);
}
#[derive(Debug)]
struct Rectangle {
width: u32,
height: u32,
}
fn main() {
let rectA = Rectangle { width: 44, height: 88 };
println!("rectA is {:?}", rectA);
}
#[derive(Debug)] struct Rectangle { width: u32, height: u32, } fn main() { let rectA = Rectangle { width: 44, height: 88 }; println!("rectA is {:?}", rectA); }
実行結果
rectA is Rectangle { width: 44, height: 88 }