pub struct Span { /* private fields */ }
Expand description
A source code location.
Essentially a lo..hi
range into a SourceMap
file’s source code.
Both lo
and hi
are offset by the file’s starting position.
Implementations§
Source§impl Span
impl Span
Sourcepub fn to_u32_range(self) -> Range<u32>
pub fn to_u32_range(self) -> Range<u32>
Returns the span as a Range<u32>
.
Sourcepub fn with_lo(self, lo: BytePos) -> Self
pub fn with_lo(self, lo: BytePos) -> Self
Creates a new span with the same hi position as this span and the given lo position.
Sourcepub fn with_hi(self, hi: BytePos) -> Self
pub fn with_hi(self, hi: BytePos) -> Self
Creates a new span with the same lo position as this span and the given hi position.
Sourcepub fn shrink_to_lo(self) -> Self
pub fn shrink_to_lo(self) -> Self
Creates a new span representing an empty span at the beginning of this span.
Sourcepub fn shrink_to_hi(self) -> Self
pub fn shrink_to_hi(self) -> Self
Creates a new span representing an empty span at the end of this span.
Sourcepub fn split_at(self, pos: u32) -> (Self, Self)
pub fn split_at(self, pos: u32) -> (Self, Self)
Splits a span into two composite spans around a certain position.
Sourcepub fn to(self, end: Self) -> Self
pub fn to(self, end: Self) -> Self
Returns a Span
that would enclose both self
and end
.
Note that this can also be used to extend the span “backwards”:
start.to(end)
and end.to(start)
return the same Span
.
____ ___
self lorem ipsum end
^^^^^^^^^^^^^^^^^^^^
Sourcepub fn between(self, end: Self) -> Self
pub fn between(self, end: Self) -> Self
Returns a Span
between the end of self
to the beginning of end
.
____ ___
self lorem ipsum end
^^^^^^^^^^^^^
Sourcepub fn until(self, end: Self) -> Self
pub fn until(self, end: Self) -> Self
Returns a Span
from the beginning of self
until the beginning of end
.
____ ___
self lorem ipsum end
^^^^^^^^^^^^^^^^^
Sourcepub fn join_many(spans: impl IntoIterator<Item = Self>) -> Self
pub fn join_many(spans: impl IntoIterator<Item = Self>) -> Self
Joins all the spans in the given iterator using to
.
Sourcepub fn join_first_last(
spans: impl IntoIterator<Item = Self, IntoIter: DoubleEndedIterator>,
) -> Self
pub fn join_first_last( spans: impl IntoIterator<Item = Self, IntoIter: DoubleEndedIterator>, ) -> Self
Joins the first and last span in the given iterator.
Trait Implementations§
Source§impl Ord for Span
impl Ord for Span
Source§impl PartialOrd for Span
impl PartialOrd for Span
impl Copy for Span
impl Eq 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
self
to key
and returns true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more