Skip to main content

ct_regex/
haystack.rs

1//! A collection of traits and structs that form the haystack system. Although usually inferred,
2//! these type may be needed on occasion for full type names etc.
3//!
4//! Additionally, it is be possible to implement these traits for other types to allow matching
5//! different strings and haystacks, but not all of the traits will be required.
6//!
7//! The main traits in this crate are chained together with associated items:
8//! ```no_run
9//! # trait Sealed {}
10//! trait HaystackItem: Sealed {}
11//!
12//! trait HaystackSlice<'a> {
13//!     type Item: HaystackItem;
14//! }
15//!
16//! trait Haystack<'a> {
17//!     type Slice: HaystackSlice<'a>;
18//! }
19//! ```
20//!
21//! The primary types that will fill these roles are:
22//!
23//! - `Item`: [`char`]
24//! - `Slice<'a>`: [`&'a str`](str)
25//! - `Haystack<'a>`: [`StrStack<'a>`]
26//!
27//! but byte-based types may also be used:
28//!
29//! - `Item`: [`u8`]
30//! - `Slice<'a>`: [`&'a [u8]`](slice)
31//! - `Haystack<'a>`: [`ByteStack<'a>`]
32//!
33//! It needs to be noted that regardless of the haystack type being matched, the regular expression
34//! provided to the `regex!` macro needs to be valid UTF-8.
35
36#[allow(unused_imports)]
37pub use ct_regex_internal::haystack::ext::*;
38pub use ct_regex_internal::haystack::{ByteStack, Haystack, HaystackItem, OwnedHaystackable, HaystackOf, HaystackSlice, IntoHaystack, StrStack};
39
40#[cfg(feature = "arcstr")]
41#[doc(cfg(feature = "arcstr"))]
42pub use ct_regex_internal::haystack::arcstr;
43
44#[cfg(feature = "bstr")]
45#[doc(cfg(feature = "bstr"))]
46pub use ct_regex_internal::haystack::bstr;
47
48#[cfg(feature = "hipstr")]
49#[doc(cfg(feature = "hipstr"))]
50pub use ct_regex_internal::haystack::hipstr;