#![feature(specialization)] trait Thingable { fn thing(&self) -> &str; } struct Delegator(Option); struct Delegate {} impl Thingable for Delegate { fn thing(&self) -> &'static str { "Delegate implementation" } } impl Thingable for Delegator { default fn thing(&self) -> &str { "Default implementation" } } impl Thingable for Delegator { fn thing(&self) -> &str { self.0.as_ref().map(|d| d.thing()).unwrap_or("Default implmementation") } } fn main() { let d: Delegator = Delegator(None); println!("{}", d.thing()); let d: Delegator = Delegator(Some(42)); println!("{}", d.thing()); let d: Delegator = Delegator(None); println!("{}", d.thing()); let d: Delegator = Delegator(Some(Delegate {})); println!("{}", d.thing()); }