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§
Sourcefn line_col_at(&self, pos: usize) -> (usize, usize)
fn line_col_at(&self, pos: usize) -> (usize, usize)
Returns the line and column number of this Position.
Sourcefn line_span_at(&self, pos: usize) -> (usize, usize)
fn line_span_at(&self, pos: usize) -> (usize, usize)
Returns the start and the end of the line that contains the position at pos.
Sourcefn span_with_context_lines(
&self,
start: usize,
end: usize,
context_lines_before: usize,
context_lines_after: usize,
) -> (usize, usize)
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.