Struct typst_syntax::Span
source · pub struct Span(/* private fields */);
Expand description
A unique identifier for a syntax node.
This is used throughout the compiler to track which source section an error or element stems from. Can be mapped back to a byte range for user facing display.
During editing, the span values stay mostly stable, even for nodes behind an insertion. This is not true for simple ranges as they would shift. Spans can be used as inputs to memoized functions without hurting cache performance when text is inserted somewhere in the document other than the end.
Span ids are ordered in the syntax tree to enable quickly finding the node with some id:
- The id of a parent is always smaller than the ids of any of its children.
- The id of a node is always greater than any id in the subtrees of any left sibling and smaller than any id in the subtrees of any right sibling.
This type takes up 8 bytes and is null-optimized (i.e. Option<Span>
also
takes 8 bytes).
Implementations§
Trait Implementations§
source§impl PartialEq for Span
impl PartialEq for Span
impl Copy for Span
impl Eq for Span
impl StructuralPartialEq for Span
Auto Trait Implementations§
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin 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