Skip to main content

add_exclude_pattern

Function add_exclude_pattern 

Source
pub fn add_exclude_pattern(existing: &mut Vec<String>, pattern: String) -> bool
Expand description

Add a pattern only when non-empty and not already present (after normalization).

Returns true when the pattern was inserted.

ยงExamples

use tokmd_exclude::add_exclude_pattern;

let mut patterns = vec![];
assert!(add_exclude_pattern(&mut patterns, "out/bundle".to_string()));
assert!(!add_exclude_pattern(&mut patterns, "./out/bundle".to_string())); // duplicate
assert!(!add_exclude_pattern(&mut patterns, String::new())); // empty
assert_eq!(patterns.len(), 1);