Guest User

Untitled

a guest
Nov 15th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. struct MyLock;
  2.  
  3. impl MyLock {
  4. fn read(&self) -> Foo {
  5. Foo {}
  6. }
  7. }
  8. struct Foo;
  9.  
  10. impl Foo {
  11. fn val(&self) -> i32 {
  12. 2
  13. }
  14. }
  15.  
  16. impl Drop for Foo
  17. {
  18. fn drop(&mut self) {
  19. println!("Dropping Foo!");
  20. }
  21. }
  22.  
  23.  
  24. fn main() {
  25. let l = MyLock {};
  26. let v = l.read().val();
  27. println!("v: {}", v);
  28. }
Add Comment
Please, Sign In to add comment