A Rust library for finding the first matching item in a directory.
Add the following to your Cargo.toml
:
toml
[dependencies]
futures="^0.3.21"
search_dir = "0.1"
```rust use futures::executor::blockon; use searchdir::search::{find_item, ItemType}; use std::env; use std::fs;
fn main() -> std::io::Result<()> { //creates directory we want to search fs::createdirall("./some/dir")?; let currentdir = env::currentdir()?;
//searches for a directory called `dir`
let found_path = block_on(find_item(
current_dir.into(),
"dir".to_string(),
ItemType::Directory,
))?
.unwrap();
println!("{:?}", found_path);
Ok(())
} ```
This project is licensed under Apache License, Version 2.0