pub struct Span(pub Range<u32>);
Expand description
Starting and ending positions of some token inside the source code.
Tuple Fields§
§0: Range<u32>
Implementations§
Source§impl Span
impl Span
Sourcepub fn combine(&self, other: &Self) -> Self
pub fn combine(&self, other: &Self) -> Self
Returns a new Span
that combines this span with other
.
The resulting span goes from self.start()
to other.end()
.
Sourcepub fn contains(&self, other: &Self) -> bool
pub fn contains(&self, other: &Self) -> bool
Returns true if this span completely contains other
.
Both the start and end of the other
span must be within the limits of
this span.
assert!(Span(0..3).contains(&Span(0..2)));
assert!(Span(0..3).contains(&Span(1..3)));
assert!(Span(0..3).contains(&Span(0..3)));
assert!(!Span(0..3).contains(&Span(0..4)));
assert!(!Span(0..3).contains(&Span(3..4)));
Sourcepub fn subspan(&self, start: usize, end: usize) -> Span
pub fn subspan(&self, start: usize, end: usize) -> Span
Returns a new Span
that is a subspan of the original one.
start
and end
are the starting and ending offset of the subspan,
relative to the start of the original span.
Trait Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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§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
Compare self to
key
and return true
if they are equal.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