pub struct Pattern { /* private fields */ }Expand description
A compiled pattern, matched by simulating a Thompson automaton: no backtracking and no recursion over the text, so matching costs time linear in the text times the size of the pattern, and constant stack, whatever the text.
Implementations§
Source§impl Pattern
impl Pattern
Sourcepub fn new(pattern: &str) -> Result<Pattern, PatternError>
pub fn new(pattern: &str) -> Result<Pattern, PatternError>
Compiles pattern, or says which part of it is outside the supported subset.
Sourcepub fn is_match(&self, text: &str) -> bool
pub fn is_match(&self, text: &str) -> bool
Whether the pattern matches anywhere in text, as new RegExp(pattern, "u").test(text) does.
Sourcepub fn is_match_with_work(&self, text: &str) -> (bool, u64)
pub fn is_match_with_work(&self, text: &str) -> (bool, u64)
Pattern::is_match and the number of automaton states it visited, which is at most a constant times the
text’s length plus one, times the number of states of the pattern.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Pattern
impl Freeze for Pattern
impl Move for Pattern
impl RefUnwindSafe for Pattern
impl Send for Pattern
impl Sync for Pattern
impl Unpin for Pattern
impl UnsafeUnpin for Pattern
impl UnwindSafe for Pattern
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