Function aklat::utils::fs::path_to_root [] [src]

pub fn path_to_root(path: &Path) -> String

Takes a path and returns a path containing just enough ../ to point to the root of the given path.

This is mostly interesting for a relative path to point back to the directory from where the path starts.

let mut path = Path::new("some/relative/path");

println!("{}", path_to_root(&path));

Outputs

"../../"

note: it's not very fool-proof, if you find a situation where it doesn't return the correct path. Consider submitting a new issue or a pull-request to improve it.