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) -> Span
pub fn new(start: usize, end: usize) -> Span
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.
Trait Implementations§
source§impl PartialEq for Span
impl PartialEq for Span
impl Copy for Span
impl Eq for Span
impl StructuralEq 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