Indexer

Trait Indexer 

Source
pub trait Indexer {
    // Required methods
    fn line_col_at(&self, pos: usize) -> (usize, usize);
    fn line_span_at(&self, pos: usize) -> (usize, usize);
    fn span_with_context_lines(
        &self,
        start: usize,
        end: usize,
        context_lines_before: usize,
        context_lines_after: usize,
    ) -> (usize, usize);
}
Expand description

A indexable string.

Required Methods§

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 + n + context_lines_after) lines that contains the span from start to end.

context_lines_before and context_lines_after specify how many lines before and after the span to include.

If there are not enough lines before or after, it will include as many as possible. And if context_lines_before or context_lines_after is zero, no extra lines will be included.

Implementations on Foreign Types§

Source§

impl<T> Indexer for &T
where T: Indexer + ?Sized,

Source§

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

Source§

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

Source§

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

Source§

impl<T> Indexer for Box<T>
where T: Indexer + ?Sized,

Source§

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

Source§

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

Source§

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

Source§

impl<T> Indexer for Rc<T>
where T: Indexer + ?Sized,

Source§

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

Source§

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

Source§

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

Source§

impl<T> Indexer for Arc<T>
where T: Indexer + ?Sized,

Source§

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

Source§

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

Source§

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

Implementors§