drop-dir

Crates.iodrop-dir
lib.rsdrop-dir
version0.1.0
sourcesrc
created_at2020-03-25 21:32:41.426045
updated_at2020-03-25 21:58:43.967053
descriptionA simple crate for self-dropping (RAII) directories.
homepage
repositoryhttps://github.com/webern/webern-rs
max_upload_size
id222785
size5,005
Matthew James Briggs (webern)

documentation

README

drop-dir

A very simple crate for creating RAII directories.

Example

use std::path::PathBuf;
use drop_dir::DropDir;
use std::fs::File;

let drop_dir = DropDir::new(PathBuf::from("/tmp/some/path")).unwrap();
let mut file = File::create(drop_dir.path().join("file.txt")).unwrap();
// drop_dir deleted when it goes out of scope.

Limitation

In the example above, only the last component of the drop_dir is removed. That is, the dir /tmp/some/temp/path is deleted, but /tmp/some/temp remains. Any other behavior would get complicated.

Commit count: 8

cargo fmt