9 unstable releases (4 breaking)

Uses new Rust 2024

0.5.0 Aug 22, 2025
0.4.3 May 28, 2025
0.4.1 Mar 12, 2025
0.4.0 Feb 22, 2025
0.1.1 Sep 26, 2024

#1040 in Filesystem

Download history 3993/week @ 2025-10-16 6585/week @ 2025-10-23 6881/week @ 2025-10-30 5340/week @ 2025-11-06 5840/week @ 2025-11-13 8565/week @ 2025-11-20 3686/week @ 2025-11-27 2665/week @ 2025-12-04 3811/week @ 2025-12-11 2427/week @ 2025-12-18 843/week @ 2025-12-25 1990/week @ 2026-01-01 2855/week @ 2026-01-08 5283/week @ 2026-01-15 13145/week @ 2026-01-22 9978/week @ 2026-01-29

31,857 downloads per month
Used in workspace_root

MIT license

24KB
390 lines

Get Dir

A utility to get directory.

This utility searches for a target directory by checking for any directories or files that match the provided input.

Usage

Get directory by target with the following code:

use std::path::PathBuf;

use get_dir::{
    GetDir,
    Target,
    DirTarget,
};

let path: PathBuf = GetDir::new()
    .target(
        Target::Dir(DirTarget::new("src")),
    )
    .run()
    .unwrap();

Or get directory by target in reverse with the following code:

use std::path::PathBuf;

use get_dir::{
    GetDir,
    Target,
    FileTarget,
};

let path: PathBuf = GetDir::new()
    .target(
        Target::File(FileTarget::new("LICENSE")),
    )
    .run_reverse()
    .unwrap();

Async version also available with async_std, smol and tokio features:

use std::path::PathBuf;

use get_dir::{
    GetDir,
    Target,
    DirTarget,
    // async_std
    async_std::GetDirAsyncExt,
    // smol
    smol::GetDirAsyncExt,
    // tokio
    tokio::GetDirAsyncExt,
};

let path: PathBuf = GetDir::new()
    .target(
        Target::Dir(DirTarget::new("src")),
    )
    .run_async()
    .await
    .unwrap();

See also

For resolving the root of a workspace, consider using the workspace_root library.

License

This project is licensed under the terms of the MIT license.

Dependencies

~0–5MB
~110K SLoC