Skip to main content

Searcher

Struct Searcher 

Source
pub struct Searcher { /* private fields */ }
Expand description

A query compiled for searching.

Implementations§

Source§

impl Searcher

Source

pub fn new(query: &SearchQuery) -> Result<Self, SearchError>

Source

pub fn options(&self) -> &SearchOptions

Source

pub fn find_next( &self, doc: &Document, from: ByteOffset, ) -> Option<Range<ByteOffset>>

The first match starting at or after from.

Source

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.

Source

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).

Source

pub fn find_all( &self, doc: &Document, range: Range<ByteOffset>, ) -> Vec<Range<ByteOffset>>

All matches inside range.

Source

pub fn expand( &self, doc: &Document, m: Range<ByteOffset>, replacement: &str, ) -> String

The replacement text for the match at m.

Source

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.

Source

pub fn find_in( &self, doc: &Document, sels: &SelectionSet, ) -> Vec<Range<ByteOffset>>

Matches in the ranges ranges selects.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.