is_subpath

Function is_subpath 

Source
pub fn is_subpath(base: &Path, child: &Path) -> bool
Expand description

Returns true if child is a subpath of base, lexically.

This does not access the filesystem and does not resolve symlinks.

ยงExamples

use std::path::{Path, PathBuf};
use pathx::is_subpath;

let base = Path::new("/home/user/project");
let child = Path::new("/home/user/project/src/main.rs");
assert!(is_subpath(base, child));
Examples found in repository?
examples/subpath.rs (line 8)
4fn main() {
5    // Check if a path is a subpath of another
6    let base = Path::new("/home/user/project");
7    let child = Path::new("/home/user/project/src/main.rs");
8    println!("Is subpath: {}", is_subpath(base, child));
9}