2 个稳定版本
1.0.1 | 2021 年 7 月 1 日 |
---|---|
0.1.0 |
|
#102 in #fs
用于 rm-node
11KB
85 行
概述
此 crate 允许快速轻松地删除文件和文件夹。它具有异步和跨平台支持。
此 crate 中的许多函数直接调用 std::fs
和 tokio::fs
。
此 crate 旨在成为
- 快速
- 易于使用
- 强大
示例
非异步实现
use delete::{delete_file};
fn main() {
// Delete file.txt
delete_file("file.txt").unwrap();
}
use delete::{delete_folder};
fn main() {
// Delete tests folder
delete_folder("tests").unwrap();
}
异步实现
use delete::{delete_file_async};
#[tokio::main]
async fn main() {
// Delete file.txt asynchronously
delete_file_async("file.txt").await.unwrap();
}
use delete::{delete_folder_async};
#[tokio::main]
async fn main() {
// Delete tests folder asynchronously
delete_folder_async("tests").await.unwrap();
}
快速实现
use delete::{rapid_delete_dir_all};
#[tokio::main]
async fn main() {
// 2-3x faster than std::fs::remove_dir_all
// removes all files and folders in subfolders recursively using tokio workers
rapid_delete_dir_all("node_modules", None, None).await;
}
致谢
依赖
~4–5MB
~88K SLoC