pub struct Span { /* private fields */ }
Expand description
A source code span, used for error reporting.
Implementations§
source§impl Span
impl Span
pub const UNDEFINED: Self = _
sourcepub const fn new(start: u32, end: u32) -> Self
pub const fn new(start: u32, end: u32) -> Self
Creates a new Span
from a range of byte indices
Note: end is exclusive, it doesn’t belong to the Span
sourcepub const fn until(&self, other: &Self) -> Self
pub const fn until(&self, other: &Self) -> Self
Returns a new Span
starting at self
and ending at other
sourcepub fn subsume(&mut self, other: Self)
pub fn subsume(&mut self, other: Self)
Modifies self
to contain the smallest Span
possible that
contains both self
and other
sourcepub fn total_span<T: Iterator<Item = Self>>(from: T) -> Self
pub fn total_span<T: Iterator<Item = Self>>(from: T) -> Self
Returns the smallest Span
possible that contains all the Span
s
defined in the from
iterator
sourcepub fn to_range(self) -> Option<Range<usize>>
pub fn to_range(self) -> Option<Range<usize>>
Converts self
to a range if the span is not unknown
sourcepub fn is_defined(&self) -> bool
pub fn is_defined(&self) -> bool
Check whether self
was defined or is a default/unknown span
sourcepub fn location(&self, source: &str) -> SourceLocation
pub fn location(&self, source: &str) -> SourceLocation
Return a SourceLocation
for this span in the provided source.
Trait Implementations§
source§impl PartialEq for Span
impl PartialEq for Span
impl Copy 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 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