Maybe the best solution, but I came up with just to define a dummy structure containing the structure that I want to change, and then I can select the cherries which methods I want to rewrite and which I want to keep the default value. To extend the original example:
trait SomeTrait { fn get_num(self) -> uint; fn add_to_num(self) -> uint { self.get_num() + 1 } } struct SomeStruct; impl SomeTrait for SomeStruct { fn get_num(self) -> uint { 3 } fn add_to_num(self) -> uint { self.get_num() + 2 } } fn main() { struct SomeOtherStruct { base: SomeStruct } impl SomeTrait for SomeOtherStruct { fn get_num(self) -> uint { self.base.get_num() }
source share