pub struct Span {
pub start: usize,
pub end: usize,
}Expand description
Represents a span of text in the input for error reporting.
Spans provide precise location information including both byte positions and line/column coordinates for better error reporting and debugging.
Fields§
§start: usizeStart position in the input (byte offset)
end: usizeEnd position in the input (byte offset)
Implementations§
Source§impl Span
impl Span
Sourcepub fn contains(&self, position: usize) -> bool
pub fn contains(&self, position: usize) -> bool
Checks if this span contains the given position.
Sourcepub fn to_enhanced(&self, input: &str) -> EnhancedSpan
pub fn to_enhanced(&self, input: &str) -> EnhancedSpan
Converts this span to an enhanced span with line/column information.
Sourcepub fn extract<'a>(&self, input: &'a str) -> &'a str
pub fn extract<'a>(&self, input: &'a str) -> &'a str
Extracts the text covered by this span from the input.
Sourcepub fn context_window(&self, input: &str, context_size: usize) -> ContextWindow
pub fn context_window(&self, input: &str, context_size: usize) -> ContextWindow
Returns a context window around this span.
Trait Implementations§
impl Copy for Span
impl Eq for Span
impl StructuralPartialEq for Span
Auto Trait Implementations§
impl Freeze for Span
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin for Span
impl UnsafeUnpin for Span
impl UnwindSafe for Span
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> 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