normalize_path_components

Function normalize_path_components 

Source
pub fn normalize_path_components(path: &Path) -> Vec<String>
Expand description

Pure function: Extract meaningful path components

Filters out current directory (.) and root components, preserving only the meaningful path segments. This enables cross-platform matching by focusing on the actual file path structure rather than platform-specific prefixes.

§Examples

use std::path::Path;
use debtmap::risk::path_normalization::normalize_path_components;

let components = normalize_path_components(Path::new("./src/lib.rs"));
assert_eq!(components, vec!["src", "lib.rs"]);

let components = normalize_path_components(Path::new("/abs/path/src/lib.rs"));
assert_eq!(components, vec!["abs", "path", "src", "lib.rs"]);

§Platform Differences

On Windows:

let components = normalize_path_components(Path::new(r"C:\Users\dev\src\lib.rs"));
assert_eq!(components, vec!["Users", "dev", "src", "lib.rs"]);

§Performance

O(n) where n is the number of path components. Single-pass iteration with no filesystem I/O.