acta-build 0.0.0

Build-time helper for acta path width calculation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use walkdir::WalkDir;

pub fn walk_src_max_width(dir: &str, strip_prefix: &str) -> usize {
   WalkDir::new(dir)
        .into_iter()
        .filter_map(|e| e.ok())
        .filter(|e| e.path().extension().is_some_and(|ext| ext == "rs"))
        .map(|e| {
            let display = e.path().to_string_lossy().replace('\\', "/");
            display
                .find(strip_prefix)
                .map(|i| &display[i + strip_prefix.len()..])
                .unwrap_or(&display)
                .len()
        })
       .max()
       .unwrap_or(16) + 4
}