pub fn module_key(
path: &str,
module_roots: &[String],
module_depth: usize,
) -> StringExpand description
Compute a “module key” from an input path.
Rules:
- Root-level files become “(root)”.
- If the first directory segment is in
module_roots, joinmodule_depthdirectory segments. - Otherwise, module key is the top-level directory.
§Examples
use tokmd_model::module_key;
let roots = vec!["crates".to_string()];
assert_eq!(module_key("crates/foo/src/lib.rs", &roots, 2), "crates/foo");
assert_eq!(module_key("src/lib.rs", &roots, 2), "src");
assert_eq!(module_key("Cargo.toml", &roots, 2), "(root)");