Module pattern
The string Pattern API.
The Pattern API provides a generic mechanism for using different pattern types when searching through a string.
For more details, see the traits Pattern, Searcher,
ReverseSearcher, and DoubleEndedSearcher.
Although this API is unstable, it is exposed via stable APIs on the
str type.
Examples
Pattern is implemented in the stable API for
[&str]str, char, slices of char, and functions and closures
implementing FnMut(char) -> bool.
let s = "Can you find a needle in a haystack?";
// &str pattern
assert_eq!;
// char pattern
assert_eq!;
// array of chars pattern
assert_eq!;
// slice of chars pattern
assert_eq!;
// closure pattern
assert_eq!;
Structs
-
CharArrayRefSearcher
Associated type for
<&[char; N] as Pattern>::Searcher<'a>. -
CharArraySearcher
Associated type for
<[char; N] as Pattern>::Searcher<'a>. -
CharPredicateSearcher
Associated type for
<F as Pattern>::Searcher<'a>. -
CharSearcher
Associated type for
<char as Pattern>::Searcher<'a>. -
CharSliceSearcher
Associated type for
<&[char] as Pattern>::Searcher<'a>. -
StrSearcher
Associated type for
<&str as Pattern>::Searcher<'a>.
Enums
-
SearchStep
Result of calling [
Searcher::next()] or [ReverseSearcher::next_back()]. -
Utf8Pattern
Result of calling [
Pattern::as_utf8_pattern()]. Can be used for inspecting the contents of aPatternin cases where the underlying representation can be represented as UTF-8.
Traits
-
DoubleEndedSearcher
A marker trait to express that a
ReverseSearchercan be used for aDoubleEndedIteratorimplementation. - Pattern A string pattern.
- ReverseSearcher A reverse searcher for a string pattern.
- Searcher A searcher for a string pattern.