3 ms·
You're correct, that crate doesn't solve the cycle problem. There is a different way of doing arenas in Rust that does though. What you do is you put all of yo
by trishume 9y ago
You're correct, that crate doesn't solve the cycle problem. There is a different way of doing arenas in Rust that does though.
What you do is you put all of your tree nodes in a big Vec<Node> and instead of referring to children and parents via pointers, you do so via indices. It's less convenient because you have to pass around a reference to your "arena" everywhere (the Vec or a slice of it), and it incurs bounds checks (pretty cheap though). But, it solves the problem in a way that is guaranteed safe.