2 releases

Uses new Rust 2024

new 0.1.1 Mar 12, 2025
0.1.0 Feb 22, 2025

#1386 in Filesystem

Download history 125/week @ 2025-02-19 14/week @ 2025-02-26

139 downloads per month

MIT license

9KB

Workspace Root

An utility to get workspace root.

The functions will try to get the workspace root by searching for the Cargo.lock file. Then it will return the directory that contains the file. If the file is not found, an error will be returned instead.

Usage

Get workspace root with the following code:

use std::path::PathBuf;

use workspace_root::get_workspace_root;

let root: PathBuf = get_workspace_root();

Async version also available with async-std/async_std and tokio features:

// This is a `async-std` example

use async_std::path::PathBuf;

use workspace_root::async_std::get_workspace_root_async;

let root: PathBuf = get_workspace_root_async().await;
// This is a `tokio` example

use std::path::PathBuf;

use workspace_root::tokio::get_workspace_root_async;

let root: PathBuf = get_workspace_root_async().await;

License

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


lib.rs:

Workspace Root

An utility to get workspace root.

The functions will try to get the workspace root by searching for the Cargo.lock file. Then it will return the directory that contains the file. If the file is not found, an error will be returned instead.

Usage

Get workspace root with the following code:

use std::path::PathBuf;

use workspace_root::get_workspace_root;

let root: PathBuf = get_workspace_root();

Async version also available with async-std/async_std and tokio features:

// This is a `async-std` example

use async_std::path::PathBuf;

use workspace_root::async_std::get_workspace_root_async;

let root: PathBuf = get_workspace_root_async().await;
// This is a `tokio` example

use std::path::PathBuf;

use workspace_root::tokio::get_workspace_root_async;

let root: PathBuf = get_workspace_root_async().await;

Dependencies

~0–10MB
~122K SLoC