try_into_collapsed

Function try_into_collapsed 

Source
pub fn try_into_collapsed(path: impl Into<Utf8PathBuf>) -> Option<Utf8PathBuf>
Expand description

Same as into_collapsed except that if Component::Prefix or Component::RootDir is encountered in a path that is supposed to be relative, or if the path attempts to navigate above its starting point using .., it returns None.

Useful for ensuring a path stays within a certain relative directory structure.