Guest User

Untitled

a guest
Oct 23rd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. use std::ops::Deref;
  2.  
  3. struct M;
  4.  
  5. impl M {
  6. fn foo(&self) {
  7. println!("Called foo on M");
  8. }
  9. }
  10.  
  11. struct S {
  12. m: M
  13. }
  14.  
  15. impl Deref for S {
  16. type Target = M;
  17. fn deref<'a>(&'a self) -> &'a Self::Target {
  18. &self.m
  19. }
  20. }
  21.  
  22. fn main() {
  23. let s = S { m: M };
  24. s.foo();
  25. }
Add Comment
Please, Sign In to add comment