pub struct Span<'a> {
pub file: &'a str,
pub bytes: ByteSpan,
pub expanded_from: Option<&'a Span<'a>>,
pub included_from: Option<&'a Span<'a>>,
}Expand description
A representation of a unique location in a source file
If the file was included from another file (using the #include
directive), Span::included_from will reference the Span
of the include directive
If the Span is part of a #define directive, each expanded
text macro will have the original Span of the #define token,
with Span::expanded_from referencing the macro expansion
directive
Fields§
§file: &'a str§bytes: ByteSpan§expanded_from: Option<&'a Span<'a>>§included_from: Option<&'a Span<'a>>Implementations§
Source§impl<'a> Span<'a>
impl<'a> Span<'a>
Sourcepub fn compare(&self, other: &Self) -> SpanRelation
pub fn compare(&self, other: &Self) -> SpanRelation
Compare two Spans, returning the relationship of the first to the second
let span1 = Span {
file: "test",
bytes: ByteSpan { start: 0, end: 2 },
expanded_from: None,
included_from: None
};
let span2 = Span {
file: "test",
bytes: ByteSpan { start: 6, end: 8 },
expanded_from: None,
included_from: None
};
assert_eq!(span1.compare(&span2), SpanRelation::Earlier)Expanded Spans will be compared starting at their expansion
point, and working backwards through #defines. Included Spans
will be compared starting at their first #include and working
through the include hierarchy to their final token.
Trait Implementations§
impl<'a> Eq for Span<'a>
impl<'a> StructuralPartialEq for Span<'a>
Auto Trait Implementations§
impl<'a> Freeze for Span<'a>
impl<'a> RefUnwindSafe for Span<'a>
impl<'a> Send for Span<'a>
impl<'a> Sync for Span<'a>
impl<'a> Unpin for Span<'a>
impl<'a> UnsafeUnpin for Span<'a>
impl<'a> UnwindSafe for Span<'a>
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