Function common_ancestor

Source
pub fn common_ancestor(a: &Path, b: &Path) -> Option<PathBuf>
Expand description

Finds the common ancestor of both paths

ยงExamples

use foundry_compilers_core::utils::common_ancestor;
use std::path::{Path, PathBuf};

let foo = Path::new("/foo/bar/foo");
let bar = Path::new("/foo/bar/bar");
let ancestor = common_ancestor(foo, bar).unwrap();
assert_eq!(ancestor, Path::new("/foo/bar"));