The crate exposes iterator-based match and split operations.
The StringZillableBinary trait yields these iterators; the underlying FindMatches, RFindMatches, FindSplits, and RFindSplits structs can also be constructed directly from a Matcher.
Trait methods, each taking a borrowed needle &'a N:
For direct construction, a Matcher<'a> names what to look for, Matcher::Substring(needle) or Matcher::Bytes(set), and the iterator type picks the direction: FindMatches and FindSplits search front to back, RFindMatches and RFindSplits back to front.
An inverted Byteset matches the bytes outside the set.
Policies are compile-time markers, opted into with builder methods: .overlapping() (default NonOverlapping, like str::matches) and .skip_empty() (default KeepEmpty, like str::split):
An empty needle matches at every offset, n + 1 times in an n-byte haystack, like "abc".matches("").
An empty separator never splits, so the whole haystack comes back as one segment.
API
StructFindSplitsAn iterator over the segments of a byte slice between the matches of a pattern, front to back.2
By default empty segments are kept, mirroring str::split, so adjacent separators and a
leading or trailing one yield empty slices. Call Self::skip_empty to drop them.
Empty needle and empty haystack
An empty needle never splits, yielding the whole haystack as one segment. An empty haystack
yields one empty segment, mirroring "".split(",") == [""].
By default empty segments are kept, mirroring str::rsplit. Call Self::skip_empty to
drop them. An empty needle never splits, yielding the whole haystack as one segment.
TraitSplitPartsWhich parts a Utf8Split yields, as a compile-time (FIRST, STRIDE) over the span boundaries: the segments between separators, the separators themselves, or both interleaved losslessly.2
A batch's boundaries are 0, each separator's start and end, and the end of the text once the
batch reaches it; part k spans boundaries k and k + 1, and Parts walks them as (FIRST, STRIDE), so all three modes share one formula. A batch holding STEPS separators stops at the
end of its last one, where the next batch begins.
Lossless (concatenation
reproduces the input) only when empties are kept; the Empty policy carries through the
type, so .skip_empty() and .with_separators() compose in either order.