https://github.com/alpheustangs/workspace_root.rs
An utility to get workspace root
https://github.com/alpheustangs/workspace_root.rs
dir directory filesystem fs root rust workspace
Last synced: 11 months ago
JSON representation
An utility to get workspace root
- Host: GitHub
- URL: https://github.com/alpheustangs/workspace_root.rs
- Owner: alpheustangs
- License: mit
- Created: 2025-02-22T09:26:04.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-02-23T14:26:52.000Z (11 months ago)
- Last Synced: 2025-02-23T15:29:13.533Z (11 months ago)
- Topics: dir, directory, filesystem, fs, root, rust, workspace
- Language: Rust
- Homepage: https://docs.rs/workspace_root
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.
## Installation
To install this package, run the following command:
```bash
cargo add workspace_root
```
## Usage
Get workspace root with the following code:
```rust
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:
```rust
// 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;
```
```rust
// 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.