pub trait PatternFilter<'a, T>
where T: Sized,
{ // Required method fn pattern_filter(&'a self, pattern: &str, case_insensitive: bool) -> Vec<T>; // Provided methods fn pattern_filter_ci(&'a self, pattern: &str) -> Vec<T> { ... } fn pattern_filter_cs(&'a self, pattern: &str) -> Vec<T> { ... } fn pattern_filter_word( &'a self, pattern: &str, case_insensitive: bool ) -> Vec<T> { ... } fn pattern_filter_word_ci(&'a self, pattern: &str) -> Vec<T> { ... } fn pattern_filter_word_cs(&'a self, pattern: &str) -> Vec<T> { ... } }
Expand description

Trait with methods to filter arrays or vectors of strings by regular expression patterns Only pattern_filter() method needs to be implemented. Both implementations ensure the regex is compiled only once. If the regex fails, filters will not be applied.

Required Methods§

source

fn pattern_filter(&'a self, pattern: &str, case_insensitive: bool) -> Vec<T>

Filter an array of strs by the pattern

Provided Methods§

source

fn pattern_filter_ci(&'a self, pattern: &str) -> Vec<T>

Filters strings in case-insensitive mode

source

fn pattern_filter_cs(&'a self, pattern: &str) -> Vec<T>

Filters strings in case-sensitive mode

source

fn pattern_filter_word( &'a self, pattern: &str, case_insensitive: bool ) -> Vec<T>

Filters strings by whole word regex patterns with case-insensitive flag

source

fn pattern_filter_word_ci(&'a self, pattern: &str) -> Vec<T>

Filters strings by whole word regex patterns in case-insensitive mode

source

fn pattern_filter_word_cs(&'a self, pattern: &str) -> Vec<T>

Filters strings by whole word regex patterns in case-sensitive mode

Implementations on Foreign Types§

source§

impl<'a> PatternFilter<'a, &'a str> for [&str]

source§

fn pattern_filter(&'a self, pattern: &str, case_insensitive: bool) -> Vec<&str>

Filter an array of strs by the pattern

source§

impl<'a> PatternFilter<'a, String> for [String]

source§

fn pattern_filter( &'a self, pattern: &str, case_insensitive: bool ) -> Vec<String>

Filter an array of strs by the pattern

Implementors§