Skip to main content

PatternFilter

Trait PatternFilter 

Source
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

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'a, T: AsRef<str> + Clone> PatternFilter<'a, T> for [T]

Filter arrays or vectors of any string-like type (&str, String, etc.), returning a Vec of the same element type.

Source§

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

Filter an array of strs by the pattern

Implementors§