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§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)