2 unstable releases

0.3.0 Feb 9, 2025
0.2.0 Feb 1, 2025

#314 in Build Utils

Download history 109/week @ 2025-01-28 144/week @ 2025-02-04 41/week @ 2025-02-11

294 downloads per month
Used in 3 crates

Apache-2.0

11KB

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.

Dependencies

~0.5–1MB
~21K SLoC