Skip to main content

HaystackItem

Trait HaystackItem 

Source
pub trait HaystackItem:
    Debug
    + Default
    + Copy
    + Eq
    + Ord
    + Sealed {
    // Required methods
    fn collect_from_str(value: &str) -> Vec<Self>;
    fn collect_from_bytes(value: &[u8]) -> Vec<Self>;
    fn is_newline(self) -> bool;
    fn is_return(self) -> bool;
}
Expand description

A trait that represents an individual item that can be matched against a Regex. The primary (and only) two implementers are char and u8.

§Sealed

This trait is sealed, preventing implementations because the regex! macro can’t produce Regex types that match against any HaystackItem other than the default. If you need to match against another item type and want to use this crate, you may as well fork it so that you don’t have to write manual Matcher expressions.

Required Methods§

Source

fn collect_from_str(value: &str) -> Vec<Self>

Creates a Vec of this item from the provided &str, used to convert string literals from parsed regular expressions into individual HaystackItems that can be matched in a haystack.

Source

fn collect_from_bytes(value: &[u8]) -> Vec<Self>

Creates a Vec of this item from the provided &[u8], used to convert a series of bytes to match from parsed regular expressions into individual HaystackItems.

Source

fn is_newline(self) -> bool

Check is this item is a newline character (‘\n’ or b’\n’). Used for string and line anchoring.

Source

fn is_return(self) -> bool

Check is this item is a carriage return character (‘\r’ or b’\r’). Used for string and line anchoring.

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.

Implementations on Foreign Types§

Source§

impl HaystackItem for char

Source§

impl HaystackItem for u8

Implementors§