std::str::pattern::Pattern - Rust (original) (raw)
Trait std::str::pattern::Pattern [−] [src]
pub trait Pattern<'a> { type Searcher: Searcher<'a>; fn into_searcher(self, haystack: &'a str) -> Self::Searcher;
fn [is_contained_in](#method.is%5Fcontained%5Fin)(self, haystack: &'a [str](../../primitive.str.html)) -> [bool](../../primitive.bool.html) { ... }
fn [is_prefix_of](#method.is%5Fprefix%5Fof)(self, haystack: &'a [str](../../primitive.str.html)) -> [bool](../../primitive.bool.html) { ... }
fn [is_suffix_of](#method.is%5Fsuffix%5Fof)(self, haystack: &'a [str](../../primitive.str.html)) -> [bool](../../primitive.bool.html)
where
Self::Searcher: ReverseSearcher<'a>,
{ ... }
}
🔬 This is a nightly-only experimental API. (pattern
#27721)
API not fully fleshed out and ready to be stabilized
A string pattern.
A Pattern<'a>
expresses that the implementing type can be used as a string pattern for searching in a &'a str
.
For example, both 'a'
and "aa"
are patterns that would match at index 1
in the string "baaaab"
.
The trait itself acts as a builder for an associatedSearcher
type, which does the actual work of finding occurrences of the pattern in a string.
type [Searcher](#associatedtype.Searcher): [Searcher](../../../std/str/pattern/trait.Searcher.html "trait std::str::pattern::Searcher")<'a>
🔬 This is a nightly-only experimental API. (pattern
#27721)
API not fully fleshed out and ready to be stabilized
Associated searcher for this pattern
fn [into_searcher](#tymethod.into%5Fsearcher)(self, haystack: &'a [str](../../primitive.str.html)) -> Self::[Searcher](../../../std/str/pattern/trait.Pattern.html#associatedtype.Searcher "type std::str::pattern::Pattern::Searcher")
🔬 This is a nightly-only experimental API. (pattern
#27721)
API not fully fleshed out and ready to be stabilized
Constructs the associated searcher fromself
and the haystack
to search in.
fn [is_contained_in](#method.is%5Fcontained%5Fin)(self, haystack: &'a [str](../../primitive.str.html)) -> [bool](../../primitive.bool.html)
🔬 This is a nightly-only experimental API. (pattern
#27721)
API not fully fleshed out and ready to be stabilized
Checks whether the pattern matches anywhere in the haystack
fn [is_prefix_of](#method.is%5Fprefix%5Fof)(self, haystack: &'a [str](../../primitive.str.html)) -> [bool](../../primitive.bool.html)
🔬 This is a nightly-only experimental API. (pattern
#27721)
API not fully fleshed out and ready to be stabilized
Checks whether the pattern matches at the front of the haystack
`fn is_suffix_of(self, haystack: &'a str) -> bool where
Self::Searcher: ReverseSearcher<'a>, `
🔬 This is a nightly-only experimental API. (pattern
#27721)
API not fully fleshed out and ready to be stabilized
Checks whether the pattern matches at the back of the haystack
impl<'a> Pattern<'a> for [char](../../primitive.char.html) type [Searcher](#associatedtype.Searcher) = [CharSearcher](../../../std/str/pattern/struct.CharSearcher.html "struct std::str::pattern::CharSearcher")<'a>;
impl<'a, 'b, 'c> Pattern<'a> for &'c &'b [str](../../primitive.str.html) type [Searcher](#associatedtype.Searcher) = [StrSearcher](../../../std/str/pattern/struct.StrSearcher.html "struct std::str::pattern::StrSearcher")<'a, 'b>;
impl<'a, 'b> Pattern<'a> for [&'b [](../../primitive.slice.html)[char](../../primitive.char.html)[]](../../primitive.slice.html) type [Searcher](#associatedtype.Searcher) = [CharSliceSearcher](../../../std/str/pattern/struct.CharSliceSearcher.html "struct std::str::pattern::CharSliceSearcher")<'a, 'b>;
impl<'a, F> Pattern<'a> for F where F: [FnMut](../../../std/ops/trait.FnMut.html "trait std::ops::FnMut")([char](../../primitive.char.html)) -> [bool](../../primitive.bool.html), type [Searcher](#associatedtype.Searcher) = [CharPredicateSearcher](../../../std/str/pattern/struct.CharPredicateSearcher.html "struct std::str::pattern::CharPredicateSearcher")<'a, F>;
impl<'a, 'b> Pattern<'a> for &'b [str](../../primitive.str.html) type [Searcher](#associatedtype.Searcher) = [StrSearcher](../../../std/str/pattern/struct.StrSearcher.html "struct std::str::pattern::StrSearcher")<'a, 'b>;
impl<'a, 'b> Pattern<'a> for &'b [String](../../../std/string/struct.String.html "struct std:🧵:String") type [Searcher](#associatedtype.Searcher) = <&'b [str](../../primitive.str.html) as [Pattern](../../../std/str/pattern/trait.Pattern.html "trait std::str::pattern::Pattern")<'a>>::[Searcher](../../../std/str/pattern/trait.Pattern.html#associatedtype.Searcher "type std::str::pattern::Pattern::Searcher");