2 ms·
I had to use recursion to build a tree in AoC '22 day 7. I needed to have both a mutable stack of current tree nodes (`cwd` if you like) and the tree structure.
by rich_sasha 4y ago
I had to use recursion to build a tree in AoC '22 day 7. I needed to have both a mutable stack of current tree nodes (`cwd` if you like) and the tree structure. Or equivalently a doubly-linked tree, where nodes point at their parent. It was a bit ugly.
In C++ you just write it.
I get why it's hard in Rust, just saying, it really does crop up.
- worik 4y agoYes. It is hard on garbage collection too, circular structures.