Skip to main content

HighlightCursor

Struct HighlightCursor 

Source
pub struct HighlightCursor<'a> { /* private fields */ }
Expand description

Highlight::covering for a caller walking the document in order — which is every painter, since a frontend draws rows top to bottom and glyphs left to right.

The one-shot form is a scan from the front of the list per glyph, and a document with two hundred search hits pays that two hundred times a row. A range that ends at or before an offset can never cover that offset or any later one, so the cursor retires those permanently and each glyph costs the ranges that actually reach it. The answer is identical to Highlight::covering’s, offset for offset — this is the same scan with the part that was being redone dropped, not a cheaper approximation.

Offsets are expected to arrive non-decreasing. One that goes backwards is still answered correctly: the cursor re-seats to the front, since a painter that revisits a row is asking a question the retired ranges may own again.

Implementations§

Source§

impl<'a> HighlightCursor<'a>

Source

pub fn new(highlights: &'a [Highlight]) -> Self

Source

pub fn at(&mut self, offset: usize) -> Option<&'a Highlight>

The range covering offset, advancing the cursor past every range that can no longer cover anything.

Auto Trait Implementations§

§

impl<'a> Freeze for HighlightCursor<'a>

§

impl<'a> RefUnwindSafe for HighlightCursor<'a>

§

impl<'a> Send for HighlightCursor<'a>

§

impl<'a> Sync for HighlightCursor<'a>

§

impl<'a> Unpin for HighlightCursor<'a>

§

impl<'a> UnsafeUnpin for HighlightCursor<'a>

§

impl<'a> UnwindSafe for HighlightCursor<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.