pub fn diff_utf8_paths<P, B>(path: P, base: B) -> Option<Utf8PathBuf>
Expand description
Construct a relative UTF-8 path from a provided base directory path to the provided path.
use camino::*;
use pathdiff::diff_utf8_paths;
let baz = "/foo/bar/baz";
let bar = "/foo/bar";
let quux = "/foo/bar/quux";
assert_eq!(diff_utf8_paths(bar, baz), Some("../".into()));
assert_eq!(diff_utf8_paths(baz, bar), Some("baz".into()));
assert_eq!(diff_utf8_paths(quux, baz), Some("../quux".into()));
assert_eq!(diff_utf8_paths(baz, quux), Some("../baz".into()));
assert_eq!(diff_utf8_paths(bar, quux), Some("../".into()));
assert_eq!(diff_utf8_paths(&baz, &bar.to_string()), Some("baz".into()));
assert_eq!(diff_utf8_paths(Utf8Path::new(baz), Utf8Path::new(bar).to_path_buf()), Some("baz".into()));