99.9% of the time you're never going to touch voodoo like this. Unless you choose that path.
99.9% of the time you're never going to touch voodoo like this. Unless you choose that path.
That and, I just wrap everything "hard" in some combination of lazy_static / Arc+Mutex.
It'd be neat if the language had a "beginner mode" flag where the compiler could recommend simple things like abuse of the heap. All you need is a day or two with it, then you can take off the training wheels.
Write one to throw away. Learning is messy and hands-on, not rote and academic.
When data flows downwards it's often simple to have the top layer own and then pass down references.
But if you start running into lots of issues doing that it's probably a fundamental issue with your architecture. So you need to either rethink it or give up and try a different kind of approach. Both are valid, but I think people who try to muddle through without either dramatic option are the ones who end up very frustrated with Rust.
Reading your comment I had two simultaneous thoughts....
1. <squinting appreciatively> Clever, cool way to think of it... ...and if you need information back at the top level, send it back via a Result....
2. <brows raised in horror, shuddering in React> State management hell!
:->