pub struct Search { /* private fields */ }Expand description
A pattern, with its case sensitivity already decided.
Implementations§
Source§impl Search
impl Search
Sourcepub fn new(pattern: impl Into<String>) -> Self
pub fn new(pattern: impl Into<String>) -> Self
Compile a pattern. Empty is legal and matches nothing, which is what makes n with
no previous search a no-op rather than a jump to row 0.
pub fn pattern(&self) -> &str
pub fn is_empty(&self) -> bool
Sourcepub fn spans(&self, haystack: &str) -> Vec<(usize, usize)>
pub fn spans(&self, haystack: &str) -> Vec<(usize, usize)>
Byte ranges of every match, for highlighting.
Offsets are into haystack exactly as given, not into a lowercased copy. Case
folding can change a string’s byte length, İ lowercases to two chars, so folding
first and reusing the resulting offsets would slice the original in the wrong place
and eventually panic on a char boundary. Scanning char by char costs more and is
always right, and this only ever runs over the rows actually on screen.
Trait Implementations§
impl Eq for Search
impl StructuralPartialEq for Search
Auto Trait Implementations§
impl Freeze for Search
impl RefUnwindSafe for Search
impl Send for Search
impl Sync for Search
impl Unpin for Search
impl UnsafeUnpin for Search
impl UnwindSafe for Search
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more