2021-04-18から1日間の記事一覧
github.com use std::ops::Deref; struct Foo; impl Foo { fn m(&self) { println!("hello, I'm Foo"); } } struct Bar { f: Foo, } impl Deref for Bar { type Target = Foo; fn deref(&self) -> &Foo { &self.f } } fn main() { let bar = Bar { f: Foo, }…