Proposal: an approach to back references

I have no idea.

In my naivety it seems that if one wants a memory safe tree with parent pointers there has to be some overhead somewhere.

I'd be inclined to lean toward the "do it in a vector" approach. Perhaps some adopting some existing Entity Component System. Not that I have much experience of doing such things apart from my experiment to generate graphs for the tunnels of the Hunt The Wumpus Game: When is a linked list not a linked list?

Arguably it does not. Rust's ownership system is designed to prevent memory use problems like use after free, double free, use of uninitialized data, race conditions etc.

When one puts everything in a Vec the ownership system is still preventing those memory use errors. It's just that now ones errors in using pointers, memory use errors, have now been reduced to program logic bugs that may produce incorrect results, like any other logic error. The thing is still thing is still memory safe though, so one is in a far better position.

2 Likes