Crate cicero_path

Crate cicero_path 

Source
Expand description

§Cicero Path

Access paths in your repository, with compile-time checks.

use cicero_path::repo_path;

let readme = repo_path!("README.md");
let doc_index = repo_path!("doc/src/index.md");

The macro checks whether the path exists and constructs a PathBuf. If the path does not exist, the compiler will error during compilation:

use cicero_path::repo_path;

let non_existent = repo_path!("non/existent/path.txt");

This allows you to move files around without having to worry that a reference silently breaks, similar to the way std::include!() works.

§How it works

During compilation, the macro looks for the .git directory to determine the root of your repository.
Then it joins the path you specified to the root and checks if the resulting path exists.

The path of your repository root is cached during compilation, so that you can use repo_path!() many times without a significant compile-time burden.

Macros§

custom_base_path_macro
Generate your own macro similar to repo_path!(), but with paths resolved relative to a custom base path. This is useful, when your Rust code is in a sub-directory of the repository, or you have a specific directory that you need to reference regularly.
repo_path
Easily construct a [std::path::PathBuf] for static paths in your repository.

Functions§

target_dir
The target/ directory of your workspace.
workspace_cargo_toml
Cargo.toml file at the root of your workspace.
workspace_dir
Root of your Cargo workspace. This is the directory where your Cargo.lock file and target/ folder is placed.