Skip to main content

Haystack

Trait Haystack 

Source
pub trait Haystack {
    // Required methods
    fn try_make_contiguous(&mut self);
    fn is_contiguous(&self) -> bool;
    fn len(&self) -> usize;
    fn substr_from<'a>(&'a self, offset: usize) -> Option<Cow<'a, str>>;
    fn substr<'a>(&'a self, from: usize, to: usize) -> Cow<'a, str>;
    fn byte_to_char(&self, byte_idx: usize) -> Option<usize>;
    fn char_to_byte(&self, char_idx: usize) -> Option<usize>;
    fn iter_from(
        &self,
        from: usize,
    ) -> Option<impl Iterator<Item = (usize, char)>>;
    fn iter_between(
        &self,
        from: usize,
        to: usize,
    ) -> impl Iterator<Item = (usize, char)>;
    fn rev_iter_between(
        &self,
        from: usize,
        to: usize,
    ) -> impl Iterator<Item = (usize, char)>;
}
Expand description

Something that can be searched over by a Regex.

The interface exposed by this trait supports searching over streaming data if needed but at the cost of reduced performance.

Required Methods§

Source

fn try_make_contiguous(&mut self)

Source

fn is_contiguous(&self) -> bool

Source

fn len(&self) -> usize

Source

fn substr_from<'a>(&'a self, offset: usize) -> Option<Cow<'a, str>>

Source

fn substr<'a>(&'a self, from: usize, to: usize) -> Cow<'a, str>

Source

fn byte_to_char(&self, byte_idx: usize) -> Option<usize>

Source

fn char_to_byte(&self, char_idx: usize) -> Option<usize>

Source

fn iter_from(&self, from: usize) -> Option<impl Iterator<Item = (usize, char)>>

Source

fn iter_between( &self, from: usize, to: usize, ) -> impl Iterator<Item = (usize, char)>

Source

fn rev_iter_between( &self, from: usize, to: usize, ) -> impl Iterator<Item = (usize, char)>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Haystack for &str

Source§

fn try_make_contiguous(&mut self)

Source§

fn is_contiguous(&self) -> bool

Source§

fn len(&self) -> usize

Source§

fn substr_from<'a>(&'a self, offset: usize) -> Option<Cow<'a, str>>

Source§

fn substr<'a>(&'a self, from: usize, to: usize) -> Cow<'a, str>

Source§

fn byte_to_char(&self, byte_idx: usize) -> Option<usize>

Source§

fn char_to_byte(&self, char_idx: usize) -> Option<usize>

Source§

fn iter_from(&self, from: usize) -> Option<impl Iterator<Item = (usize, char)>>

Source§

fn iter_between( &self, from: usize, to: usize, ) -> impl Iterator<Item = (usize, char)>

Source§

fn rev_iter_between( &self, from: usize, to: usize, ) -> impl Iterator<Item = (usize, char)>

Implementors§