Get the Components of a Directory Path as a Vec in Rust
September 2025
Note that this converts to lossy strings so some info may be lost if the paths have characters that don't otherwise convert.
TODO: Verify UTF-8 is safe from degredation.
use PathBuf;
Output:
[_active_nvim_run:12:5] get_path_as_vec(&path) = [
"file.txt",
]
[_active_nvim_run:12:5] get_path_as_vec(&path) = [
"sub-dir",
"file.txt",
]
[_active_nvim_run:12:5] get_path_as_vec(&path) = [
"/",
"at-root.txt",
]
[_active_nvim_run:12:5] get_path_as_vec(&path) = [
"/",
"sub-dir",
"file.txt",
]
end of line