Function common_path::common_path

source ·
pub fn common_path<P, Q>(one: P, two: Q) -> Option<PathBuf>where
    P: AsRef<Path>,
    Q: AsRef<Path>,
Expand description

Find the common prefix, if any, between 2 paths

Example

use std::path::{PathBuf, Path};
use common_path::common_path;

let baz = Path::new("/foo/bar/baz");
let quux = Path::new("/foo/bar/quux");
let prefix = common_path(baz, quux).unwrap();
assert_eq!(prefix, Path::new("/foo/bar").to_path_buf());