Expand description
A collection of traits and structs that form the haystack system. Although usually implicit, these type may be needed on occasion for full type names etc.
Additionally, it is be possible to implement these traits for other types to allow matching different strings and other types, but not all of the traits will be required.
The main traits in this crate are chained together with associated items:
trait HaystackItem {}
trait HaystackSlice<'a> {
type Item: HaystackItem;
}
trait HaystackIter<'a> {
type Slice: HaystackSlice<'a>;
}The primary types that will fill these roles are:
Item:charSlice<'a>:&'a strHaystackIter<'a>:StrStack<'a>
but byte-based types may also be used:
Item:u8Slice<'a>:&'a [u8]HaystackIter<'a>:ByteStack<'a>
It needs to be noted that regardless of the haystack type being matched, the regular expression
provided to the regex! macro needs to be valid UTF-8.
Modules§
- arcstr
arcstr - Extra haystack implementations for the
arcstrcrate. - bstr
bstr - Extra haystack implementations for the
bstrcrate. - hipstr
hipstr - Extra haystack implementations for the
hipstrcrate.
Structs§
- Byte
Stack - A haystack type for matching against the
u8s in a&[u8]. This type provides very straightforward indexing and iteration over the contained slice. - StrStack
- A haystack type for matching against the
chars in a&str. This type abstracts over the variable width scalars contained, to allow indexing without panics.
Traits§
- Haystack
- A trait used to interface the haystack types use when matching of capturing against a
Regex, including tracking progression and slicing captures. - Haystack
Item - A trait that represents an individual item that can be matched against a
Regex. The primary (and only) two implementors arecharandu8. - Haystack
Iter - The main underlying trait for
Haystacktypes,HaystackItershould be implemented on new types that understand slicing and iterating over a haystack that can be sliced into instances ofSelf::Slice. - Haystack
Of - This trait is exactly the same as
Haystack, except that it simplifies bounds by requiring thatItem = I. - Haystack
Slice - A trait representing a slice of the underlying haystack for various
Haystacktypes. - Into
Haystack - A trait that is responsible for converting a slice into a stateful
Haystack, of typeH. The primary intent of this trait is to allow users to avoid creating their ownHaystack, instead passing a slice to methods onRegex.