Created
November 10, 2014 03:51
-
-
Save XMPPwocky/ee8fb2a4c7a253bbf968 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Base<T: Derived> { | |
x: u32, | |
derived: T | |
} | |
trait Derived { | |
fn foo_the_bars(&mut self, base: &mut Base) -> u32; | |
} | |
struct SomeDerived { | |
y: u32 | |
} | |
impl Derived for SomeDerived { | |
fn foo_the_bars(&mut self, base: &mut Base) -> u32 { | |
self.y += 1; | |
base.x + self.y | |
} | |
} | |
impl Derived for Box<Derived> { | |
fn foo_the_bars(&mut self, base: &mut Base) -> u32 { | |
**self.foo_the_bars(base) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment