Trait collections::str::pattern::ReverseSearcher
[−]
[src]
pub unsafe trait ReverseSearcher<'a>: Searcher<'a> { fn next_back(&mut self) -> SearchStep; fn next_match_back(&mut self) -> Option<(usize, usize)> { ... } fn next_reject_back(&mut self) -> Option<(usize, usize)> { ... } }
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
`Searchertypes of the
`
types of the Pattern
`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 them
parent trait Searcher
`Searcher`.
Required Methods
fn next_back(&mut self) -> SearchStep
Performs the next search step starting from the back.
- Returns
Match(a, b)
`Match(a, b)if
` ifhaystack[a..b]
`haystack[a..b]` matches the pattern. - Returns
Reject(a, b)
`Reject(a, b)if
` ifhaystack[a..b]
`haystack[a..b]` can not match the pattern, even partially. - Returns
Done
`Done` if every byte of the haystack has been visited
The stream of Match
`Matchand
` and Reject
`Rejectvalues up to a
` values up to a Done
`Done`
will contain index ranges that are adjacent, non-overlapping,
covering the whole haystack, and laying on utf8 boundaries.
A Match
`Matchresult needs to contain the whole matched pattern, however
` result needs to contain the whole matched pattern,
however Reject
`Reject` results may be split up into arbitrary
many adjacent fragments. Both ranges may have zero length.
As an example, the pattern "aaa"
`"aaa"and the haystack
` and the haystack "cbaaaaab"
`"cbaaaaab"might produce the stream
`
might produce the stream
[Reject(7, 8), Match(4, 7), Reject(1, 4), Reject(0, 1)]
`[Reject(7, 8), Match(4, 7), Reject(1, 4), Reject(0, 1)]`
Provided Methods
fn next_match_back(&mut self) -> Option<(usize, usize)>
Find the next Match
`Matchresult. See
` result. See next_back()
`next_back()`
fn next_reject_back(&mut self) -> Option<(usize, usize)>
Find the next Reject
`Rejectresult. See
` result. See next_back()
`next_back()`
Implementors
impl<'a, C> ReverseSearcher<'a> for CharEqSearcher<'a, C> where C: CharEq
impl<'a, 'b> ReverseSearcher<'a> for StrSearcher<'a, 'b>
impl<'a> ReverseSearcher<'a> for CharSearcher<'a>
impl<'a, 'b> ReverseSearcher<'a> for CharSliceSearcher<'a, 'b>
impl<'a, F> ReverseSearcher<'a> for CharPredicateSearcher<'a, F> where F: FnMut(char) -> bool