pub fn path_matches_pattern(path: &Path, pattern: &str) -> boolExpand description
Checks whether a path matches a /-separated pattern by whole components
The pattern’s components must appear consecutively in the path. A trailing
slash requires the match to be a directory, i.e. at least one more path
component must follow. Substrings never match partial components, so
tests/ does not match src/attests/mod.rs and src/gen does not match
src/generic.rs.
§Arguments
path- Path to checkpattern-/-separated component pattern
§Returns
true if the pattern’s components appear consecutively in the path
§Examples
use std::path::Path;
use rust_diff_analyzer::classifier::path_classifier::path_matches_pattern;
assert!(path_matches_pattern(
Path::new("tests/integration.rs"),
"tests/"
));
assert!(path_matches_pattern(
Path::new("crate/tests/it.rs"),
"tests/"
));
assert!(!path_matches_pattern(
Path::new("src/attests/mod.rs"),
"tests/"
));
assert!(!path_matches_pattern(
Path::new("src/generic.rs"),
"src/gen"
));