pub struct Span {
pub start: u32,
pub end: u32,
}Expand description
Span represents a range of a piece of source code. It counts by byte offset, so it’s 0-based.
Offsets are u32 (matching oxc convention);
sources larger than 4 GiB are rejected by the parser up front.
Every AST node carries spans into the original source, including inline nodes, whose offsets are never derived from a rebuilt buffer.
Fields§
§start: u32Start offset. (Inclusive)
end: u32End offset. (Exclusive)
Implementations§
Source§impl Span
impl Span
pub fn new(start: u32, end: u32) -> Self
Sourcepub fn empty(at: u32) -> Self
pub fn empty(at: u32) -> Self
A zero-width span at the given offset. Covers no characters, but its position may still be meaningful (e.g. a marker between two tokens).
Sourcepub fn contains(self, offset: u32) -> bool
pub fn contains(self, offset: u32) -> bool
Whether offset lies inside the span (start <= offset < end).
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