Function common_ancestor_all

Source
pub fn common_ancestor_all<I, P>(paths: I) -> Option<PathBuf>
where I: IntoIterator<Item = P>, P: AsRef<Path>,
Expand description

Find the common ancestor, if any, between the given paths

ยงExamples

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

let baz = Path::new("/foo/bar/baz");
let bar = Path::new("/foo/bar/bar");
let foo = Path::new("/foo/bar/foo");
let common = common_ancestor_all([baz, bar, foo]).unwrap();
assert_eq!(common, Path::new("/foo/bar").to_path_buf());