#directory #file #traverse #recursive #iterate


Rtv is a crate for recursively traversing a directory using a simple API. In other words: You can easily iterate over the files inside a directory tree.

4 releases (1 stable)

1.0.0 Jul 24, 2022
0.2.1 Sep 10, 2021
0.2.0 Sep 10, 2021
0.1.2 Sep 7, 2021

#224 in Filesystem

MIT license

99 lines


build crates

This is a rust crate wich makes it easy to recursively traverse a directory or in other words, to iterate over a directory tree.

That means looking at every file inside a directory and it's subdirectories. For example consider this layout:

    │   file1
    │   file2
    │   file3
    │   │   file4
    │   │   file5
    │   │
    │   └───folder3
    │           file7

This crate provides functions to iterate over all the files, from file1 to file7.

These methods are exposed through the Traverse struct.

Here a small function that goes trough every file inside path/to/dir and its subdirectories and prints the content.

use rtv::Traverse;
use std::io::Read;

Traverse::new("path/to/dir").apply(|mut file, _| {
    let mut buff = String::new();
    file.read_to_string(&mut buff);
    println!("{}", buff);


0.2.0 -> 0.2.1

  • Added the scan_dirs function

0.1.2 -> 0.2.0

  • The callback the apply function takes, now gets the path to the file.
  • The build function now returns a Vec<PathBuf> instead of Vec<DirEntry>.

0.0.0 -> 0.1.2

  • Basic functionality.

No runtime deps