pub struct PatternSet { /* private fields */ }Expand description
A set of patterns for multi-pattern matching.
Implementations§
Source§impl PatternSet
impl PatternSet
Sourcepub fn from_patterns(patterns: Vec<Pattern>) -> Self
pub fn from_patterns(patterns: Vec<Pattern>) -> Self
Create a pattern set from a vector of patterns.
Sourcepub fn add_named(
&mut self,
name: impl Into<String>,
pattern: Pattern,
) -> &mut Self
pub fn add_named( &mut self, name: impl Into<String>, pattern: Pattern, ) -> &mut Self
Add a named pattern to the set.
Sourcepub fn find_match(&self, text: &str) -> Option<(usize, PatternMatch)>
pub fn find_match(&self, text: &str) -> Option<(usize, PatternMatch)>
Find the first matching pattern in the text.
Returns the pattern index and match details.
Sourcepub fn get(&self, index: usize) -> Option<&NamedPattern>
pub fn get(&self, index: usize) -> Option<&NamedPattern>
Get a pattern by index.
Sourcepub fn min_timeout(&self) -> Option<Duration>
pub fn min_timeout(&self) -> Option<Duration>
Get the minimum timeout from timeout patterns.
Sourcepub fn iter(&self) -> impl Iterator<Item = &NamedPattern>
pub fn iter(&self) -> impl Iterator<Item = &NamedPattern>
Get iterator over patterns.
Trait Implementations§
Source§impl Clone for PatternSet
impl Clone for PatternSet
Source§fn clone(&self) -> PatternSet
fn clone(&self) -> PatternSet
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PatternSet
impl Debug for PatternSet
Source§impl Default for PatternSet
impl Default for PatternSet
Source§fn default() -> PatternSet
fn default() -> PatternSet
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PatternSet
impl RefUnwindSafe for PatternSet
impl Send for PatternSet
impl Sync for PatternSet
impl Unpin for PatternSet
impl UnwindSafe for PatternSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more