How can I list all the files of a directory in Rust? I am looking for the equivalent of the following Python code.
files = os.listdir('./')
How can I list all the files of a directory in Rust? I am looking for the equivalent of the following Python code.
files = os.listdir('./')
Try this on the playground:
You may see the source.
And for walking directories recursively try this on the playground:
See walkdir, and Directory Traversal.
I hope this helps.
Here's an example:
It will simply iterate over the files and print out their names.
You could also use glob, which is expressly for this purpose.