extern crate ambassador; use ambassador::{delegatable_trait, Delegate}; #[delegatable_trait] pub trait Shout { fn shout(&self, input: &str) -> String; } pub struct Dog; impl Shout for Dog { fn shout(&self, input: &str) -> String { format!("{} - wuff!", input) } } #[derive(Delegate)] #[delegate(Shout)] pub enum Animal { Dog(Dog), } pub fn main() { let foo_animal = Animal::Dog(Dog); println!("{}", foo_animal.shout("BAR")); }