Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Foo {
- }
- enum FooChain<'a> {
- Top(&'a mut Foo),
- Child(&'a mut FooChain<'a>)
- }
- impl<'a> FooChain<'a> {
- fn child(&'a mut self) -> FooChain<'a> {
- FooChain::Child(self)
- }
- }
- fn foo<'a>(chain : &'a mut FooChain<'a>) {
- chain.child();
- }
- fn main() {
- let mut a = Foo {};
- {
- let mut b = FooChain::Top(&mut a);
- foo(&mut b);
- foo(&mut b);
- }
- }
Add Comment
Please, Sign In to add comment