trait Animal { 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 name(&self)->&'static str { self.isim } fn talk (&self) { println!("{} says hello",self.name()); } } impl Animal for Cat { fn name(&self)->&'static str { self.name } fn talk (&self) { println!("{} says meow",self.name()); } } enum Yaratik{ Human(Human), Cat(Cat) } fn traits(){ let mut yaratiklar= Vec::new(); //yaratiklar.push(Human{isim:"Enes"}); //yaratiklar.push(Cat{name:"Toprak"}); yaratiklar.push(Yaratik::Human(Human{isim:"Enes"})); yaratiklar.push(Yaratik::Cat(Cat{name:"Toprak"})); for y in yaratiklar{ match y { Yaratik::Human(h)=>h.talk(), Yaratik::Cat(c)=>c.talk() } } let mut canlilar:Vec>= Vec::new(); canlilar.push(Box::new(Human{isim:"Ahmet"})); canlilar.push(Box::new(Cat{name:"Toprak2"})); for c in canlilar.iter() { c.talk(); } } fn main() { traits(); }