1 struct Targ { 2 w:u32, 3 h:u32, 4 } 5 impl Targ { 6 fn aera(&self) -> u32 { 7 self.w * self.h 8 } 9 fn sround(&self) -> u32 { 10 (self.w + self.h ) * 2 11 } 12 fn init(x:u32, y:u32) -> Targ { 13 Targ{w:x, h:y} 14 } 15 } 16 fn main(){ 17 //let t1 = Targ{w:20, h:15}; 18 let t1 = Targ::init(25, 8); 19 println!("{}\t{}",t1.aera(),t1.sround()); 20 println!("{}\t{}",&t1.aera(),&t1.sround()); 21 }