pub struct SpanContext {
pub line_text: String,
pub line_number: usize,
pub column_start: usize,
pub column_end: usize,
}Expand description
Context around an error for display purposes.
Fields§
§line_text: StringThe line of source text containing the error.
line_number: usizeThe line number (1-indexed).
column_start: usizeColumn where error starts (1-indexed).
column_end: usizeColumn where error ends (1-indexed).
Implementations§
Source§impl SpanContext
impl SpanContext
Sourcepub fn from_source(source: &str, span: &SourceSpan) -> Self
pub fn from_source(source: &str, span: &SourceSpan) -> Self
Creates a context from source text and span.
Sourcepub fn format_highlight(&self) -> String
pub fn format_highlight(&self) -> String
Formats the context with error highlighting.
Returns a multi-line string showing the error line with carets (^) indicating the error location.
Trait Implementations§
Source§impl Clone for SpanContext
impl Clone for SpanContext
Source§fn clone(&self) -> SpanContext
fn clone(&self) -> SpanContext
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 moreAuto Trait Implementations§
impl Freeze for SpanContext
impl RefUnwindSafe for SpanContext
impl Send for SpanContext
impl Sync for SpanContext
impl Unpin for SpanContext
impl UnwindSafe for SpanContext
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