pub struct SourceContext {
pub lines: Vec<SourceLine>,
pub error_line_index: usize,
}Expand description
Source context for rendering
Fields§
§lines: Vec<SourceLine>Lines around the error (typically 1-3 lines before, error line, 1-3 after)
error_line_index: usizeIndex of the error line in the lines vector
Implementations§
Source§impl SourceContext
impl SourceContext
pub fn new(lines: Vec<SourceLine>, error_line_index: usize) -> SourceContext
Sourcepub fn from_source(
source: &str,
location: &SourceLocation,
span_end: Option<(usize, usize)>,
) -> SourceContext
pub fn from_source( source: &str, location: &SourceLocation, span_end: Option<(usize, usize)>, ) -> SourceContext
Build source context from source text and location
Trait Implementations§
Source§impl Clone for SourceContext
impl Clone for SourceContext
Source§fn clone(&self) -> SourceContext
fn clone(&self) -> SourceContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SourceContext
impl Debug for SourceContext
Source§impl Default for SourceContext
impl Default for SourceContext
Source§fn default() -> SourceContext
fn default() -> SourceContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SourceContext
impl RefUnwindSafe for SourceContext
impl Send for SourceContext
impl Sync for SourceContext
impl Unpin for SourceContext
impl UnsafeUnpin for SourceContext
impl UnwindSafe for SourceContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more