Struct pomsky_syntax::Span
source · pub struct Span { /* private fields */ }
Expand description
A source code location, marked by the start and end byte offset. If both are
zero, this is considered as “empty” or “missing”, and Span::range
returns None
.
Implementations§
source§impl Span
impl Span
sourcepub fn new(start: usize, end: usize) -> Self
pub fn new(start: usize, end: usize) -> Self
Constructs a new Span
. If both start
and end
is 0, this is
considered as “empty” or “missing”
sourcepub fn range(self) -> Option<Range<usize>>
pub fn range(self) -> Option<Range<usize>>
Converts this span to a std::ops::Range
. If it is empty, None
is
returned.
sourcepub fn range_unchecked(self) -> Range<usize>
pub fn range_unchecked(self) -> Range<usize>
Converts this span to a std::ops::Range
, without checking if it is
empty.