Skip to main content

Crate acta_build

Crate acta_build 

Source
Expand description

Build-time helper for acta.

Call from your build.rs to compute a sensible default path_width for acta::Formatter based on the longest source-file path in your project.

§Example

Add to your Cargo.toml:

[build-dependencies]
acta-build = "0.1"

In build.rs:

let width = acta_build::walk_src_max_width("src", "src/");
println!("cargo:rustc-env=ACTA_PATH_WIDTH={width}");
println!("cargo:rerun-if-changed=src");

Then in your code:

ⓘ
let width: usize = env!("ACTA_PATH_WIDTH").parse().unwrap_or(40);
let formatter = acta::Formatter::new().with_path_width(width);

Functions§

walk_src_max_width
Walk dir recursively, find every .rs file, and return max(path_len_after_stripping(strip_prefix)) + 4.