I could probably optimize that by getting the iterators for all 4
directions and then to the scan on each of them in a loop, but I'm with
with this right now.
Took multiple seconds to run, so I wonder if there's a more efficient
way to do this. Maybe would be better to have a Vec<Vec<usize>> instead
of putting all lines after each other.
I don't know, it doesn't feel like this is proper code. Referencing the
same object multiple times is just so much of a hassle and this code
looks pretty unsafe with all the unwraps.
In the end it turns out that I don't need a tree, but need to iterate
over all directories instead, which is again something quite hard for
me, because I don't know how to build iterators "manually".
Borrow-checker hindered me to keep the same HashSet around all the time
and just clear it, so it feels a little inefficient to have a new set
every time.
I feel like there should be away for me to read from the back and move
things over directly instead of having a temporary Vec for it, but I'm
not sure how this would work with the owner-checking, so I didn't try.
I'm not sure why this is so much to write. It feels like there should be
a more generic way to check this instead of duplicating those lines, but
maybe it's not worth it for 2 ranges ...