rust - How to print structs and arrays? -


go seems able print structs , arrays directly.

struct mystruct {     a: i32,     b: i32 } 

and

let arr: [i32; 10] = [1; 10]; 

you want implement debug trait on struct. using #[derive(debug)] easiest solution. can print {:?}:

#[derive(debug)] struct mystruct{     a: i32,     b: i32 }  fn main() {     let x = mystruct{ a: 10, b: 20 };     println!("{:?}", x); } 

Comments

Popular posts from this blog

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -

javascript - three.js lot of meshes optimization -