pub struct DropDir { /* private fields */ }Expand description
Represents a Directory that will be automatically deleted when it goes out of scope.
§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.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DropDir
impl RefUnwindSafe for DropDir
impl Send for DropDir
impl Sync for DropDir
impl Unpin for DropDir
impl UnwindSafe for DropDir
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more