pub fn module_name(rel: &Path) -> StringExpand description
The crate-relative module path for a source file, given its path relative
to the crate source root. The crate root file (lib.rs / main.rs) and
any mod.rs map to their containing module; every other file adds its stem.
ยงExamples
use std::path::Path;
use coding_tools::modgraph::module_name;
assert_eq!(module_name(Path::new("lib.rs")), "crate");
assert_eq!(module_name(Path::new("main.rs")), "crate");
assert_eq!(module_name(Path::new("domain.rs")), "domain");
assert_eq!(module_name(Path::new("domain/mod.rs")), "domain");
assert_eq!(module_name(Path::new("domain/entity.rs")), "domain::entity");