pub trait Haystack<'a>: HaystackIter<'a> {
// Provided methods
fn is_start(&self) -> bool { ... }
fn is_end(&self) -> bool { ... }
fn item(&self) -> Option<Self::Item> { ... }
fn index(&self) -> usize { ... }
fn progress(&mut self) { ... }
fn slice(&self, cap: Range<usize>) -> Self::Slice { ... }
fn reset(&mut self) { ... }
fn rollback(&mut self, state: usize) -> &mut Self { ... }
}Expand description
A trait used to interface the haystack types use when matching of capturing against a
Regex, including tracking progression and slicing captures.
It is rare that users will have to interact with this trait, appart from Trait bounds. All
public methods will take an impl IntoHaystack<'a, H> as an argument.
Haystack is accompanied by another trait, HaystackItem, representing items that can be
matched against a Regex.
Haystacks are stateful and therefore can’t be matched against multiple times without being
reset first, or they will continue where the first pattern finished. They store
their state as a usize, which can be obtained via index and restored via
rollback. Additionally, Haystacks are cheap to clone, relying on shallow
clones or reference counting.
Provided Methods§
fn is_start(&self) -> bool
fn is_end(&self) -> bool
fn item(&self) -> Option<Self::Item>
fn index(&self) -> usize
fn progress(&mut self)
fn slice(&self, cap: Range<usize>) -> Self::Slice
fn reset(&mut self)
fn rollback(&mut self, state: usize) -> &mut Self
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.