Struct xswag_base::code::Span
[−]
[src]
pub struct Span { pub lo: BytePos, pub hi: BytePos, }
A region within the source specified by first and last byte offset. lo
byte is included in the span, hi
byte is excluded.
Fields
lo | Low byte, inclusive |
hi | High byte, exclusive |
Methods
impl Span
fn single(pos: BytePos) -> Span
Creates a span that points to a single char
fn empty_at(pos: BytePos) -> Span
Crates an empty span (points between to chars)
fn new(lo: BytePos, hi: BytePos) -> Span
Creates a span from a lo and hi (shorter than struct constructor syntax)
fn from_pair((lo, hi): (BytePos, BytePos)) -> Span
Creates a span from a tuple
fn dummy() -> Span
Creates a dummy span. Should be used with caution.
fn is_dummy(&self) -> bool
Checks if the this span is a dummy span
fn is_empty(&self) -> bool
Checks if the span is empty
fn len(&self) -> SrcOffset
Returns the length (number of bytes) of the span or 0 if it's a dummy span
fn hull(&self, other: &Self) -> Span
Returns the smallest span which encloses both given spans
If one of given spans is a dummy span, it is ignored and the other span is returned. If both spans are dummy spans, a dummy span is returned.
fn contains(&self, other: Self) -> bool
Checks if this span contains another span. A dummy span never contains any other span and is never contained in another span.
fn into_range(self) -> Range<usize>
Returns a range for indexing strings and vectors