1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| fn main() { struct User { name: String, count: String, nonce: u64, active: bool, } let xiaoming = User { name: String::from("Xiaoming"), count: String::from("80001000"), nonce: 10000, active: true, }; let mut xiaohuang = User { name: String::from("Xiaohuang"), count: String::from("80001000"), nonce: 10000, active: true, }; xiaohuang.nonce = 20000; let name = String::from("xiaoxiao"); let count = String::from("58398439"); let nonce = 20000; let active = false;
let user1 = User { name, count, nonce, active, }; let user2 = User { name = String::from("user2"), ..user1 }; println!("name = {} ",user2.name); struct Point(i32,i32); let a = Point(1,10); let b = Point(3,11);
println!("a.x = {}, a.y = {}",a.0,a.1); struct A{}; #[derive(Debug)] println!("xiaoming = {:?}",xiaoming); println!("xiaoming = {:#?}",xiaoming); }
|