pub trait Haystack: Copy + Clone {
type Cursor: HaystackCursor;
// Required methods
fn len(&self) -> usize;
fn cursor_at(&self, pos: usize) -> Self::Cursor;
fn char_at(&self, pos: usize) -> Option<(char, usize)>;
fn char_before(&self, pos: usize) -> Option<char>;
fn starts_with(&self, pos: usize, literal: &str) -> bool;
fn matches_range(
&self,
pos: usize,
other_start: usize,
other_end: usize,
) -> bool;
fn find_byte(&self, byte: u8, pos: usize) -> Option<usize>;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
A trait for text that can be searched by the regex engine. This abstraction allows searching over non-contiguous memory (like ropes) without flattening to a single string.
Required Associated Types§
type Cursor: HaystackCursor
Required Methods§
Sourcefn cursor_at(&self, pos: usize) -> Self::Cursor
fn cursor_at(&self, pos: usize) -> Self::Cursor
Get a cursor for streaming access starting at pos
Sourcefn char_before(&self, pos: usize) -> Option<char>
fn char_before(&self, pos: usize) -> Option<char>
Get character before position
Sourcefn starts_with(&self, pos: usize, literal: &str) -> bool
fn starts_with(&self, pos: usize, literal: &str) -> bool
Check if haystack starts with literal at pos
Provided Methods§
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.