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
Auto Trait Implementations§
impl Forget for CompiledSearch
impl Freeze for CompiledSearchwhere
*const ArcInner<RegexI> is !null: Freeze,
PhantomData<ArcInner<RegexI>>: Freeze,
*const Pool<Cache, Box<dyn Fn() -> Cache + Sync + UnwindSafe + RefUnwindSafe + Send>> is !null: Freeze,
PhantomData<Pool<Cache, Box<dyn Fn() -> Cache + Sync + UnwindSafe + RefUnwindSafe + Send>>>: Freeze,
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
impl Move for CompiledSearch
impl RefUnwindSafe for CompiledSearchwhere
Atomic<usize>: RefUnwindSafe,
Pool<Cache, Box<dyn Fn() -> Cache + Sync + UnwindSafe + RefUnwindSafe + Send>>: RefUnwindSafe,
impl Send for CompiledSearch
impl Sync for CompiledSearch
impl Unpin for CompiledSearch
impl UnsafeUnpin for CompiledSearchwhere
*const ArcInner<RegexI> is !null: UnsafeUnpin,
PhantomData<ArcInner<RegexI>>: UnsafeUnpin,
*const Pool<Cache, Box<dyn Fn() -> Cache + Sync + UnwindSafe + RefUnwindSafe + Send>> is !null: UnsafeUnpin,
PhantomData<Pool<Cache, Box<dyn Fn() -> Cache + Sync + UnwindSafe + RefUnwindSafe + Send>>>: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
impl UnwindSafe for CompiledSearchwhere
Arc<RegexI>: UnwindSafe,
BoxRaw<Pool<Cache, Box<dyn Fn() -> Cache + Sync + UnwindSafe + RefUnwindSafe + Send>>>: UnwindSafe,
Arc<str>: UnwindSafe,
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