pub struct CompiledPattern { /* private fields */ }Expand description
A compiled pattern for efficient reuse
Created by PatternMatcher::compile for patterns that will be
matched against multiple texts. The three operation closures share
the underlying compiled state in the adapter so that a single
pattern compilation services all three operations.
Implementations§
Source§impl CompiledPattern
impl CompiledPattern
Sourcepub fn new(
find: Box<dyn Fn(&str) -> Vec<PatternMatch> + Send + Sync>,
is_match: Box<dyn Fn(&str) -> bool + Send + Sync>,
captures: Box<dyn Fn(&str) -> Vec<Captures> + Send + Sync>,
) -> Self
pub fn new( find: Box<dyn Fn(&str) -> Vec<PatternMatch> + Send + Sync>, is_match: Box<dyn Fn(&str) -> bool + Send + Sync>, captures: Box<dyn Fn(&str) -> Vec<Captures> + Send + Sync>, ) -> Self
Build a compiled pattern from its three operation closures.
Adapters are expected to share their compiled state (e.g. an
Arc<Regex>) across the three closures so that find_matches,
is_match, and captures_iter all reuse the same compilation.
Sourcepub fn find_matches(&self, text: &str) -> Vec<PatternMatch>
pub fn find_matches(&self, text: &str) -> Vec<PatternMatch>
Find every occurrence of the pattern in text.
Sourcepub fn captures_iter(&self, text: &str) -> Vec<Captures>
pub fn captures_iter(&self, text: &str) -> Vec<Captures>
Iterate captures (full match plus groups) for every occurrence.
Auto Trait Implementations§
impl Freeze for CompiledPattern
impl !RefUnwindSafe for CompiledPattern
impl Send for CompiledPattern
impl Sync for CompiledPattern
impl Unpin for CompiledPattern
impl UnsafeUnpin for CompiledPattern
impl !UnwindSafe for CompiledPattern
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