pub struct CompiledSearch { /* private fields */ }Expand description
A search query whose regex is compiled once and can be reused across many texts.
The one-shot free functions (find_all, find_next, …) recompile the regex on every
call, which is wasteful when scanning many small texts (e.g. searching a file line-by-line, or
many files). Compile once with CompiledSearch::new and call CompiledSearch::find_all
repeatedly instead.
Implementations§
Source§impl CompiledSearch
impl CompiledSearch
Sourcepub fn new(query: &str, options: SearchOptions) -> Result<Self, SearchError>
pub fn new(query: &str, options: SearchOptions) -> Result<Self, SearchError>
Compile query under options for repeated use.
Returns SearchError::InvalidRegex if the query is an invalid regex (only possible when
options.regex is set).
Trait Implementations§
Source§impl Clone for CompiledSearch
impl Clone for CompiledSearch
Source§fn clone(&self) -> CompiledSearch
fn clone(&self) -> CompiledSearch
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CompiledSearch
impl RefUnwindSafe for CompiledSearch
impl Send for CompiledSearch
impl Sync for CompiledSearch
impl Unpin for CompiledSearch
impl UnsafeUnpin for CompiledSearch
impl UnwindSafe for CompiledSearch
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