How it works...
Walking a filesystem tree is not a particularly complicated task. However, just like any other tree walks, it is much easier to be done recursively, even though there is always a risk of running into stack overflow problems if the directory nesting is too deep. While an iterative approach is possible, it is much longer and more complicated to implement.
In this recipe, we start off with setting everything up in step 1, adding the glob crate (https://docs.rs/glob/0.3.0/glob/) as a dependency in step 2, and finally importing the required modules in step 3. In step 4, we write the first walk function, a recursive in-order walk. This means that we recursively descend as far as possible into the first (by some order) directory ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access