pub unsafe trait ReverseSearcher<'a>: Searcher<'a> {
// Required method
fn next_back(&mut self) -> SearchStep;
// Provided methods
fn next_match_back(&mut self) -> Option<(usize, usize)> { ... }
fn next_reject_back(&mut self) -> Option<(usize, usize)> { ... }
}pattern #27721)Expand description
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.
§Safety
Implementers must ensure that all trait functions abide by the
guarantees documented in the # Guarantees sections. The provided
methods automatically satisfy their guarantees.
Required Methods§
Sourcefn next_back(&mut self) -> SearchStep
🔬This is a nightly-only experimental API. (pattern #27721)
fn next_back(&mut self) -> SearchStep
pattern #27721)Performs the next search step starting from the back.
- Returns
Match(a, b)ifhaystack[a..b]matches the pattern. - Returns
Reject(a, b)ifhaystack[a..b]can not match the pattern, even partially. - Returns
Doneif every byte of the haystack has been visited
§Guarantees
- The stream of
MatchandRejectvalues up to aDonewill contain index ranges that are adjacent, non-overlapping, covering the whole haystack, and lying on utf8 boundaries.
A Match result needs to contain the whole matched
pattern, however 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§
Sourcefn next_match_back(&mut self) -> Option<(usize, usize)>
🔬This is a nightly-only experimental API. (pattern #27721)
fn next_match_back(&mut self) -> Option<(usize, usize)>
pattern #27721)Finds the next Match result. See next_back().
§Guarantees
- Every returned
Some((a, b))must satisfya <= b <= self.haystack().len(), and both endpoints must lie on UTF-8 character boundaries. - Matched ranges must be returned in forward order, without revisiting previously consumed portions of the haystack.
Sourcefn next_reject_back(&mut self) -> Option<(usize, usize)>
🔬This is a nightly-only experimental API. (pattern #27721)
fn next_reject_back(&mut self) -> Option<(usize, usize)>
pattern #27721)Finds the next Reject result. See next_back().
§Guarantees
- Every returned
Some((a, b))must satisfya <= b <= self.haystack().len(), and both endpoints must lie on UTF-8 character boundaries. - Matched ranges must be returned in forward order, without revisiting previously consumed portions of the haystack.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".