12345678910111213141516171819202122232425262728293031323334#[derive(Debug)]struct Dog { name: String, weight: f32, height: f32, }impl Dog { fn get_name(&self) -> &str { &(self.name[..]) } fn get_height(&self) -> f32 { self.height } fn sound() { println!("wang-wang-wang!"); } }impl Dog { fn get_weight(&self) -> f32 { self.weight } }fn main() { let dog = Dog { name: String::from("wangcai"), weight: 100.5, height: 70.5, }; println!("dog = {:#?}",dog); println!("name = {}",dog.get_name()); println!("weight = {}",dog.get_weight()); Dog::show(); }