Skip to main content

Haystack

Trait Haystack 

Source
pub trait Haystack<'a>: HaystackIter<'a> {
Show 13 methods // Provided methods fn item(&self) -> Option<Self::Item> { ... } fn index(&self) -> usize { ... } fn progress(&mut self) { ... } fn inner_slice(&self) -> Self::Slice { ... } fn slice_with(&self, range: Range<usize>) -> Self::Slice { ... } fn reset(&mut self) { ... } fn rollback(&mut self, state: usize) -> &mut Self { ... } fn is_start(&self) -> bool { ... } fn is_end(&self) -> bool { ... } fn is_line_start(&self) -> bool { ... } fn is_line_end(&self) -> bool { ... } fn is_crlf_start(&self) -> bool { ... } fn is_crlf_end(&self) -> bool { ... }
}
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§

Source

fn item(&self) -> Option<Self::Item>

Source

fn index(&self) -> usize

Source

fn progress(&mut self)

Source

fn inner_slice(&self) -> Self::Slice

Source

fn slice_with(&self, range: Range<usize>) -> Self::Slice

Source

fn reset(&mut self)

Source

fn rollback(&mut self, state: usize) -> &mut Self

Source

fn is_start(&self) -> bool

Source

fn is_end(&self) -> bool

Source

fn is_line_start(&self) -> bool

Source

fn is_line_end(&self) -> bool

Source

fn is_crlf_start(&self) -> bool

Source

fn is_crlf_end(&self) -> bool

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.

Implementors§

Source§

impl<'a, T> Haystack<'a> for T
where T: HaystackIter<'a>,