pub struct Searcher { /* private fields */ }Expand description
A query compiled for searching.
Implementations§
Source§impl Searcher
impl Searcher
pub fn new(query: &SearchQuery) -> Result<Self, SearchError>
pub fn options(&self) -> &SearchOptions
Sourcepub fn find_next(
&self,
doc: &Document,
from: ByteOffset,
) -> Option<Range<ByteOffset>>
pub fn find_next( &self, doc: &Document, from: ByteOffset, ) -> Option<Range<ByteOffset>>
The first match starting at or after from.
Sourcepub fn find_prev(
&self,
doc: &Document,
before: ByteOffset,
) -> Option<Range<ByteOffset>>
pub fn find_prev( &self, doc: &Document, before: ByteOffset, ) -> Option<Range<ByteOffset>>
The last match starting before before. Searches backwards in
growing windows, so a match near the caret is found quickly.
Sourcepub fn matches<'a>(
&'a self,
doc: &'a Document,
range: Range<ByteOffset>,
) -> impl Iterator<Item = Range<ByteOffset>> + 'a
pub fn matches<'a>( &'a self, doc: &'a Document, range: Range<ByteOffset>, ) -> impl Iterator<Item = Range<ByteOffset>> + 'a
The matches inside range, found as the iterator is advanced (so a
caller can stop after enough of them).
Sourcepub fn find_all(
&self,
doc: &Document,
range: Range<ByteOffset>,
) -> Vec<Range<ByteOffset>>
pub fn find_all( &self, doc: &Document, range: Range<ByteOffset>, ) -> Vec<Range<ByteOffset>>
All matches inside range.
Sourcepub fn expand(
&self,
doc: &Document,
m: Range<ByteOffset>,
replacement: &str,
) -> String
pub fn expand( &self, doc: &Document, m: Range<ByteOffset>, replacement: &str, ) -> String
The replacement text for the match at m.
Sourcepub fn ranges(
&self,
doc: &Document,
sels: &SelectionSet,
) -> Vec<Range<ByteOffset>>
pub fn ranges( &self, doc: &Document, sels: &SelectionSet, ) -> Vec<Range<ByteOffset>>
The ranges to search: the non-empty selections with “in selection” on, otherwise the whole document.
Sourcepub fn find_in(
&self,
doc: &Document,
sels: &SelectionSet,
) -> Vec<Range<ByteOffset>>
pub fn find_in( &self, doc: &Document, sels: &SelectionSet, ) -> Vec<Range<ByteOffset>>
Matches in the ranges ranges selects.
Sourcepub fn next_from(
&self,
doc: &Document,
sels: &SelectionSet,
backward: bool,
) -> Option<Range<ByteOffset>>
pub fn next_from( &self, doc: &Document, sels: &SelectionSet, backward: bool, ) -> Option<Range<ByteOffset>>
The match to select for Find Next/Previous from the current primary selection, wrapping if enabled.
Sourcepub fn replacement_for_selection(
&self,
doc: &Document,
sels: &SelectionSet,
replacement: &str,
) -> Option<(Range<ByteOffset>, String)>
pub fn replacement_for_selection( &self, doc: &Document, sels: &SelectionSet, replacement: &str, ) -> Option<(Range<ByteOffset>, String)>
If the primary selection is exactly a match, the range and its replacement text (for Replace).
Auto Trait Implementations§
impl !RefUnwindSafe for Searcher
impl !UnwindSafe for Searcher
impl Freeze for Searcher
impl Send for Searcher
impl Sync for Searcher
impl Unpin for Searcher
impl UnsafeUnpin for Searcher
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