LineIndexer

Struct LineIndexer 

Source
pub struct LineIndexer(/* private fields */);
Expand description

An Indexer that stores ending positions of every line (including trailing newlines).

Implementations§

Source§

impl LineIndexer

Source

pub fn new(s: &str) -> Box<Self>

Create an LineIndexer.

Trait Implementations§

Source§

impl Debug for LineIndexer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Indexer for LineIndexer

Source§

fn line_col_at(&self, pos: usize) -> (usize, usize)

Returns the line and column number of this Position.
Source§

fn line_span_at(&self, pos: usize) -> (usize, usize)

Returns the start and the end of the line that contains the position at pos.
Source§

fn span_with_context_lines( &self, start: usize, end: usize, context_lines_before: usize, context_lines_after: usize, ) -> (usize, usize)

Returns the start and the end of the (context_lines_before + 1 + context_lines_after) lines that contains the position at pos.
Source§

impl PartialEq for LineIndexer

Source§

fn eq(&self, other: &LineIndexer) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for LineIndexer

Source§

impl StructuralPartialEq for LineIndexer

Auto Trait Implementations§

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