trait Animal { fn create(name:&'static str) ->Self; fn name(&self)->&'static str; fn talk (&self) { println!("{} cannot talk",self.name()); } } struct Human { isim:&'static str } struct Cat { name:&'static str } impl Animal for Human { fn create(name:&'static str)->Human { Human{isim:name} } fn name(&self)->&'static str { self.isim } fn talk (&self) { println!("{} says hello",self.name()); } } impl Animal for Cat { fn create(name:&'static str)->Cat { Cat{name:name} } fn name(&self)->&'static str { self.name } fn talk (&self) { println!("{} says meow",self.name()); } } fn traits(){ //let h= Human{isim:"Enes"}; //let h=Human::create("Ahmet"); let h:Human = Animal::create("Samet"); h.talk(); let c= Cat{name:"Toprak"}; c.talk(); } fn main() { traits(); }