This gives an error that test1 has been moved. This makes perfect sense so I tried using references for the handlers instead and run into this issue
<anon>:40:23: 40:28 error: mismatched types:
expected `Box<&MyTrait>`,
found `Box<&Test0>`
(expected trait MyTrait,
found struct `Test0`) [E0308]
<anon>:40 foo.handlers.push(test0);
I also tried to use handlers: Vec<&'a Box<MyTrait>> but I'm unable to get this to work correctly. I haven't looked at Cell/RefCell yet so I'm wonder if that is the way to go?
This is fundamentally not going to work. some_fun requires unique access to the invocant, so the call to other_fun won't be allowed.
As an aside, Box<&MyTrait> isn't really useful; it's just a pointer-to-a-pointer.
If you want mutation+aliasing, yes, you will need to look into Cell/RefCell/RwLock. Actually, the first thing you should is decide whether you really want mutation + aliasing. Assuming you do, you could do something like: