utf8_path

Function path_relative_from

Source
pub fn path_relative_from(
    path: impl AsRef<Utf8Path>,
    base: impl AsRef<Utf8Path>,
) -> Result<Utf8PathBuf>
Expand description

Helper to make one path relative to a directory.

This is similar to GN’s rebase_path(path, new_base).

To do the calculation, both ‘path’ and ‘base’ are made absolute, using the current working dir as the basis for converting a relative path to absolute, and then the relative path from one to the other is computed.