Skip to main content

get_relative_path_to

Function get_relative_path_to 

Source
pub fn get_relative_path_to<'a>(from: &str, target: &'a str) -> Cow<'a, str>
Expand description

Returns the path of target relative to from, as a plain path: "c", "../c", or "." when the two are equal.

The result is not prefixed with ./, so it is a path and not a module request. Use get_relative_request_to to build an import specifier, where a bare "c" would be read as a package name rather than as a file next to from.

Returns "." by reference when the paths are identical, or target by reference when from is empty.