Guest User

Untitled

a guest
Dec 14th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. struct Foo {
  2. }
  3.  
  4. enum FooChain<'a> {
  5. Top(&'a mut Foo),
  6. Child(&'a mut FooChain<'a>)
  7. }
  8.  
  9. impl<'a> FooChain<'a> {
  10. fn child(&'a mut self) -> FooChain<'a> {
  11. FooChain::Child(self)
  12. }
  13. }
  14.  
  15. fn foo<'a>(chain : &'a mut FooChain<'a>) {
  16. chain.child();
  17. }
  18.  
  19. fn main() {
  20.  
  21. let mut a = Foo {};
  22.  
  23. {
  24. let mut b = FooChain::Top(&mut a);
  25. foo(&mut b);
  26. foo(&mut b);
  27. }
  28. }
Add Comment
Please, Sign In to add comment