Skip to main content

HaystackSlice

Trait HaystackSlice 

Source
pub trait HaystackSlice<'a>:
    Sized
    + Debug
    + Clone
    + ToOwned {
    type Item: HaystackItem;

    // Required method
    fn slice_with(&self, range: Range<usize>) -> Self;
}
Expand description

A trait representing a slice of the underlying haystack for various Haystack types.

The implementor of this trait is usually but not always, the only implementor of IntoHaystack for a haystack type.

It should be noted that this trait is often implemented of a reference to the type in question, e.g. &str or &[u8] rather than str or [u8] themselves, so that the implementing type can be cloned as required.

Required Associated Types§

Source

type Item: HaystackItem

The HaystackItem contained within this slice.

Required Methods§

Source

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

Slices the underlying slice with the provided (half-open) range, used for retrieving values of capture groups.

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<'a> HaystackSlice<'a> for &'a str

Source§

type Item = char

Source§

fn slice_with(&self, range: Range<usize>) -> &'a str

Source§

impl<'a> HaystackSlice<'a> for &'a BStr

Source§

type Item = u8

Source§

fn slice_with(&self, range: Range<usize>) -> &'a BStr

Source§

impl<'a> HaystackSlice<'a> for &'a [u8]

Source§

type Item = u8

Source§

fn slice_with(&self, range: Range<usize>) -> &'a [u8]

Source§

impl<'a> HaystackSlice<'a> for Substr

Source§

type Item = char

Source§

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

Source§

impl<'a, B> HaystackSlice<'a> for HipByt<'a, B>
where B: Backend,

Source§

type Item = u8

Source§

fn slice_with(&self, range: Range<usize>) -> HipByt<'a, B>

Source§

impl<'a, B> HaystackSlice<'a> for HipStr<'a, B>
where B: Backend,

Source§

type Item = char

Source§

fn slice_with(&self, range: Range<usize>) -> HipStr<'a, B>

Implementors§