Skip to main content

compile_name_set

Function compile_name_set 

Source
pub fn compile_name_set(spec: &str) -> Result<Vec<Regex>, Error>
Expand description

Compile a '|'-separated set of whole-name alternatives, each promoted and anchored. An entry name matches the set when it matches any alternative, mirroring find’s -name a -o -name b.

§Examples

use coding_tools::pattern::compile_name_set;

let set = compile_name_set("*.rs|*.toml").unwrap();
let matches = |name: &str| set.iter().any(|r| r.is_match(name));
assert!(matches("lib.rs"));
assert!(matches("Cargo.toml"));
assert!(!matches("README.md"));