Function rif::utils::relativize_path [−][src]
pub fn relativize_path(path: &Path) -> Result<PathBuf, RifError>
Expand description
Convert a path into a relative path
This function yields error when absolute path doesn’t start with current working directory.
Args
path
- File path to make as relative path
Example
// Current working directory is /home/user/test/example
let absolute = relativize_path(PathBuf::from("/home/user/test/example"));
assert_eq!(absolute, PathBuf::from("example"));
let dotslash = relativize_path(PathBuf::from("./test/example"));
assert_eq!(absolute, PathBuf::from("example"));