Calculates the common prefix for a set of paths, if a common prefix exists
Example
# extern crate common_path;
use ;
use common_path;
#
Or for more than 2 paths:
# extern crate common_path;
use ;
use common_path_all;
#
Calculates the common prefix for a set of paths, if a common prefix exists
# extern crate common_path;
use std::path::{PathBuf, Path};
use common_path::common_path;
# fn main() {
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());
# }
Or for more than 2 paths:
# extern crate common_path;
use std::path::{PathBuf, Path};
use common_path::common_path_all;
# fn main() {
let baz = Path::new("/foo/bar/baz");
let quux = Path::new("/foo/bar/quux");
let foo = Path::new("/foo/bar/foo");
let prefix = common_path_all(vec![baz, quux, foo]).unwrap();
assert_eq!(prefix, Path::new("/foo/bar").to_path_buf());
# }