pub struct Span {
pub start: u32,
pub end: u32,
}Fields§
§start: u32§end: u32Implementations§
Source§impl Span
impl Span
pub const fn empty() -> Self
pub fn is_empty(&self) -> bool
pub fn len(&self) -> u32
Sourcepub fn or(&self, other: Self) -> Self
pub fn or(&self, other: Self) -> Self
Return self if not empty, or the other span if self is empty
Sourcepub fn to(&self, other: Self) -> Self
pub fn to(&self, other: Self) -> Self
Get the combined span that encompasses both spans. The order does not matter.
Sourcepub fn skip(&self, skip: Self) -> Self
pub fn skip(&self, skip: Self) -> Self
Take the current span, but skip the start until the skip span has been passed
Sourcepub fn start_from(&self, start: Self) -> Self
pub fn start_from(&self, start: Self) -> Self
Take the current span, but skip the first part and start from the given start span
Sourcepub fn collapse_to_end(&self) -> Span
pub fn collapse_to_end(&self) -> Span
Discard the span and keep a zero-length span at the end value
Sourcepub fn collapse_to_start(&self) -> Span
pub fn collapse_to_start(&self) -> Span
Discard the span and keep a zero-length span at the start value
Sourcepub fn is_selected_at(&self, offset: u32) -> bool
pub fn is_selected_at(&self, offset: u32) -> bool
Returns true if a cursor at the given offset would select the span
Note that one offset can select multiple non-overlapping (but touching) spans!
Sourcepub fn until_end_of(&self, other: Self) -> Self
pub fn until_end_of(&self, other: Self) -> Self
Take the start of self until the end of other (max is end of self)
Sourcepub fn until_start_of(&self, other: Self) -> Self
pub fn until_start_of(&self, other: Self) -> Self
Take the start of self until the start of other (max is end of self)
Trait Implementations§
impl Copy for Span
impl Eq for Span
Source§impl Span for Span
impl Span for Span
Source§type Offset = u32
type Offset = u32
A type representing a span’s start or end offset from the start of the input. Read more
Source§fn new(_context: Self::Context, range: Range<Self::Offset>) -> Self
fn new(_context: Self::Context, range: Range<Self::Offset>) -> Self
Create a new span given a context and an offset range.
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 UnsafeUnpin 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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.impl<T> OrderedSeq<'_, T> for Twhere
T: Clone,
Source§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
Source§impl<T> SpanExt for T
impl<T> SpanExt for T
fn with_span(self, span: impl Into<Span>) -> Spanned<Self>where
Self: Sized,
Source§fn spanned(self, span: impl Into<Span>) -> Spanned<Self>where
Self: Sized,
fn spanned(self, span: impl Into<Span>) -> Spanned<Self>where
Self: Sized,
Same as
Self::with_span, but can avoid name collisionsfn with_dummy_span(self) -> Spanned<Self>where
Self: Sized,
fn into_with_dummy_span<T>(self) -> Spanned<T>where
Self: Into<T>,
Source§impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
Source§fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
Invokes
WrappingSpan::make_wrapped to wrap an AST node in a span.