pub struct Span {
pub start: usize,
pub end: usize,
}Expand description
Byte offset range into the source string.
start is inclusive, end is exclusive (Rust slice convention).
line_col accuracy is byte-based: for ASCII input, column equals the
visual position. Multi-byte UTF-8 characters count as one column per
code point (char boundary) for line calculation, but col is still
byte-offset from the line start — annotate accordingly if you expose
this to users with non-ASCII input.
Fields§
§start: usize§end: usizeImplementations§
Source§impl Span
impl Span
pub fn new(start: usize, end: usize) -> Self
Sourcepub fn line_col(&self, source: &str) -> (usize, usize)
pub fn line_col(&self, source: &str) -> (usize, usize)
Returns the (line, col) of self.start, both 1-based.
Sourcepub fn source_line<'a>(&self, source: &'a str) -> &'a str
pub fn source_line<'a>(&self, source: &'a str) -> &'a str
Returns the full source line that contains self.start.
pub fn is_empty(&self) -> bool
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