pub fn normalize_rel_path(path: &str) -> StringExpand description
Normalize a relative path for matching:
- converts
\to/ - strips all leading
./segments
§Examples
use tokmd_path::normalize_rel_path;
assert_eq!(normalize_rel_path("./src/main.rs"), "src/main.rs");
assert_eq!(normalize_rel_path(".\\src\\main.rs"), "src/main.rs");
assert_eq!(normalize_rel_path("../lib.rs"), "../lib.rs");
assert_eq!(normalize_rel_path("././src/lib.rs"), "src/lib.rs");Idempotency — normalizing twice gives the same result:
use tokmd_path::normalize_rel_path;
let once = normalize_rel_path(".\\src\\lib.rs");
let twice = normalize_rel_path(&once);
assert_eq!(once, twice);
assert_eq!(once, "src/lib.rs");