Function spat::shorten

source ·
pub fn shorten(path: impl AsRef<Path>) -> PathBuf
Expand description

Takes a reference to a Path and shortens all but its last component to their first characters. Dots (.) are left as is since they might refer to hidden or relative paths.

Example

let shortened = spat::shorten("/path/to/something");
assert_eq!(shortened.as_os_str(), "/p/t/something");