Trait ReverseSearcher

unsafe trait ReverseSearcher<'a>: Searcher<'a>

A reverse searcher for a string pattern.

This trait provides methods for searching for non-overlapping matches of a pattern starting from the back (right) of a string.

It will be implemented by associated Searcher types of the Pattern trait if the pattern supports searching for it from the back.

The index ranges returned by this trait are not required to exactly match those of the forward search in reverse.

For the reason why this trait is marked unsafe, see the parent trait Searcher.

Required Methods

fn next_back(self: &mut Self) -> SearchStep

Performs the next search step starting from the back.

  • Returns [Match(a, b)][SearchStep::Match] if haystack[a..b] matches the pattern.
  • Returns [Reject(a, b)][SearchStep::Reject] if haystack[a..b] can not match the pattern, even partially.
  • Returns [Done][SearchStep::Done] if every byte of the haystack has been visited

The stream of [Match][SearchStep::Match] and [Reject][SearchStep::Reject] values up to a [Done][SearchStep::Done] will contain index ranges that are adjacent, non-overlapping, covering the whole haystack, and laying on utf8 boundaries.

A [Match][SearchStep::Match] result needs to contain the whole matched pattern, however [Reject][SearchStep::Reject] results may be split up into arbitrary many adjacent fragments. Both ranges may have zero length.

As an example, the pattern "aaa" and the haystack "cbaaaaab" might produce the stream [Reject(7, 8), Match(4, 7), Reject(1, 4), Reject(0, 1)].

Provided Methods

fn next_match_back(self: &mut Self) -> Option<(usize, usize)>

Finds the next [Match][SearchStep::Match] result. See [next_back()][ReverseSearcher::next_back].

fn next_reject_back(self: &mut Self) -> Option<(usize, usize)>

Finds the next [Reject][SearchStep::Reject] result. See [next_back()][ReverseSearcher::next_back].

Implementors