Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::ops::Deref;
- struct M;
- impl M {
- fn foo(&self) {
- println!("Called foo on M");
- }
- }
- struct S {
- m: M
- }
- impl Deref for S {
- type Target = M;
- fn deref<'a>(&'a self) -> &'a Self::Target {
- &self.m
- }
- }
- fn main() {
- let s = S { m: M };
- s.foo();
- }
Add Comment
Please, Sign In to add comment