Movatterモバイル変換


[0]ホーム

URL:


Module pattern

std::str

Modulepattern 

Source
🔬This is a nightly-only experimental API. (pattern #27721)
Expand description

The string Pattern API.

The Pattern API provides a generic mechanism for using different patterntypes when searching through a string.

For more details, see the traitsPattern,Searcher,ReverseSearcher, andDoubleEndedSearcher.

Although this API is unstable, it is exposed via stable APIs on thestr type.

§Examples

Pattern isimplemented in the stable API for&str,char, slices ofchar, and functions and closuresimplementingFnMut(char) -> bool.

lets ="Can you find a needle in a haystack?";// &str patternassert_eq!(s.find("you"),Some(4));// char patternassert_eq!(s.find('n'),Some(2));// array of chars patternassert_eq!(s.find(&['a','e','i','o','u']),Some(1));// slice of chars patternassert_eq!(s.find(&['a','e','i','o','u'][..]),Some(1));// closure patternassert_eq!(s.find(|c: char| c.is_ascii_punctuation()),Some(35));

Structs§

CharArrayRefSearcherExperimental
Associated type for<&[char; N] as Pattern>::Searcher<'a>.
CharArraySearcherExperimental
Associated type for<[char; N] as Pattern>::Searcher<'a>.
CharPredicateSearcherExperimental
Associated type for<F as Pattern>::Searcher<'a>.
CharSearcherExperimental
Associated type for<char as Pattern>::Searcher<'a>.
CharSliceSearcherExperimental
Associated type for<&[char] as Pattern>::Searcher<'a>.
StrSearcherExperimental
Associated type for<&str as Pattern>::Searcher<'a>.

Enums§

SearchStepExperimental
Result of callingSearcher::next() orReverseSearcher::next_back().
Utf8PatternExperimental
Result of callingPattern::as_utf8_pattern().Can be used for inspecting the contents of aPattern in caseswhere the underlying representation can be represented as UTF-8.

Traits§

DoubleEndedSearcherExperimental
A marker trait to express that aReverseSearchercan be used for aDoubleEndedIterator implementation.
PatternExperimental
A string pattern.
ReverseSearcherExperimental
A reverse searcher for a string pattern.
SearcherExperimental
A searcher for a string pattern.

[8]ページ先頭

©2009-2026 Movatter.jp