pub struct LineBuffer {
pub scopes: Vec<ScopeSpan>,
pub styles: Vec<StyleSpan>,
/* private fields */
}Expand description
Scratch space for highlighting one line without reallocating per call.
A buffer holds the latest tokenization and styling results so callers can reuse allocations while scanning many lines or repeatedly re-highlighting a changing line.
Fields§
§scopes: Vec<ScopeSpan>Current scope spans.
styles: Vec<StyleSpan>Current style spans.
Implementations§
Source§impl LineBuffer
impl LineBuffer
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears all buffered spans while retaining allocations.
Cached scope styles are intentionally retained: they are keyed by (theme, grammar, scope_count) and stays valid across line resets.
Sourcepub fn tokenize<'a>(
&'a mut self,
grammar: &Grammar,
state: &mut LineState,
line: &str,
) -> &'a [ScopeSpan]
pub fn tokenize<'a>( &'a mut self, grammar: &Grammar, state: &mut LineState, line: &str, ) -> &'a [ScopeSpan]
Tokenizes one line into this reusable buffer.
Trait Implementations§
Source§impl Debug for LineBuffer
impl Debug for LineBuffer
Source§impl Default for LineBuffer
impl Default for LineBuffer
Source§fn default() -> LineBuffer
fn default() -> LineBuffer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LineBuffer
impl RefUnwindSafe for LineBuffer
impl Send for LineBuffer
impl Sync for LineBuffer
impl Unpin for LineBuffer
impl UnsafeUnpin for LineBuffer
impl UnwindSafe for LineBuffer
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