#path #delete #test

auto-delete-path

A simple PathBuf wrapper that gets deleted when it goes out of scope

2 unstable releases

0.2.0 May 19, 2022
0.1.0 Nov 18, 2020

#1367 in Filesystem

Download history 37/week @ 2024-07-20 47/week @ 2024-07-27 22/week @ 2024-08-03 3/week @ 2024-08-10 9/week @ 2024-08-17 13/week @ 2024-08-24 38/week @ 2024-08-31 32/week @ 2024-09-07 33/week @ 2024-09-14 49/week @ 2024-09-21 35/week @ 2024-09-28 35/week @ 2024-10-05 59/week @ 2024-10-12 50/week @ 2024-10-19 31/week @ 2024-10-26 54/week @ 2024-11-02

199 downloads per month
Used in queue-file

MIT/Apache

7KB

auto-delete-path

crates.io crates.io

A super small PathBuf wrapper that gets deleted when it goes out of scope.

Useful for writing tests that work with files and not worrying about having to delete them manually.


lib.rs:

A super small crate which contains AutoDeletePath, a path which gets automatically deleted when it goes out of scope.

Examples

{
    let tmp_path = auto_delete_path::AutoDeletePath::temp(); // creates a new path at the default temp folder
    std::fs::create_dir(&tmp_path); // AutoDeletePath implements AsRef<Path>
    let subfile = tmp_path.as_ref().join("subfile"); // create a subfile
    std::fs::File::create(&subfile).unwrap();
} // tmp_path dies here, so the directory and its contents will be deleted

See AutoDeletePath and include_to_auto_delete_path for more examples.

Dependencies

~35KB