pub struct Span { /* private fields */ }
Expand description
A source code span, used for error reporting.
Implementations§
source§impl Span
impl Span
pub const UNDEFINED: Span = _
sourcepub const fn new(start: u32, end: u32) -> Span
pub const fn new(start: u32, end: u32) -> Span
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: &Span) -> Span
pub const fn until(&self, other: &Span) -> Span
Returns a new Span
starting at self
and ending at other
sourcepub fn subsume(&mut self, other: Span)
pub fn subsume(&mut self, other: Span)
Modifies self
to contain the smallest Span
possible that
contains both self
and other
sourcepub fn total_span<T>(from: T) -> Span
pub fn total_span<T>(from: T) -> Span
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 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