pub struct SpanMap {
spans: Vec<(TextSize, Span)>,
pub matched_arm: Option<u32>,
}Expand description
Maps absolute text ranges for the corresponding file to the relevant span data.
Fields§
§spans: Vec<(TextSize, Span)>The offset stored here is the end of the node.
matched_arm: Option<u32>Index of the matched macro arm on successful expansion for declarative macros.
Implementations§
Source§impl SpanMap
impl SpanMap
Sourcepub fn finish(&mut self)
pub fn finish(&mut self)
Finalizes the SpanMap, shrinking its backing storage and validating that the offsets are
in order.
Sourcepub fn ranges_with_span_exact(
&self,
span: Span,
) -> impl Iterator<Item = (TextRange, SyntaxContext)> + '_
pub fn ranges_with_span_exact( &self, span: Span, ) -> impl Iterator<Item = (TextRange, SyntaxContext)> + '_
Returns all TextRanges that correspond to the given span.
Note this does a linear search through the entire backing vector.
Sourcepub fn ranges_with_span(
&self,
span: Span,
) -> impl Iterator<Item = (TextRange, SyntaxContext)> + '_
pub fn ranges_with_span( &self, span: Span, ) -> impl Iterator<Item = (TextRange, SyntaxContext)> + '_
Returns all TextRanges whose spans contain the given span.
Note this does a linear search through the entire backing vector.
Sourcepub fn spans_for_range(
&self,
range: TextRange,
) -> impl Iterator<Item = Span> + '_
pub fn spans_for_range( &self, range: TextRange, ) -> impl Iterator<Item = Span> + '_
Returns the spans associated with the given range. In other words, this will return all spans that correspond to all offsets within the given range.
pub fn iter(&self) -> impl Iterator<Item = (TextSize, Span)> + '_
Trait Implementations§
impl Eq for SpanMap
impl StructuralPartialEq for SpanMap
Auto Trait Implementations§
impl Freeze for SpanMap
impl !RefUnwindSafe for SpanMap
impl Send for SpanMap
impl Sync for SpanMap
impl Unpin for SpanMap
impl !UnwindSafe for SpanMap
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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