pub struct TokenSpan {
pub start: usize,
pub end: usize,
}Expand description
Byte span carried by a Token.
Fields§
§start: usizeStarting byte position.
end: usizeEnding byte position.
Implementations§
Source§impl TokenSpan
impl TokenSpan
Sourcepub fn try_new(start: usize, end: usize) -> Result<Self, TokenSpanError>
pub fn try_new(start: usize, end: usize) -> Result<Self, TokenSpanError>
Create a span, returning an error when end < start.
Sourcepub const fn contains(self, offset: usize) -> bool
pub const fn contains(self, offset: usize) -> bool
Return whether offset is inside this half-open span.
The start is inclusive and the end is exclusive, matching Rust
Range semantics. Empty spans contain no offsets.
Sourcepub const fn touches(self, offset: usize) -> bool
pub const fn touches(self, offset: usize) -> bool
Return whether offset touches this span, including the end boundary.
This is useful for cursor-oriented callers that need positions at token boundaries to resolve to the adjacent token. Empty spans touch exactly their single boundary offset.
Trait Implementations§
impl Copy for TokenSpan
impl Eq for TokenSpan
impl StructuralPartialEq for TokenSpan
Auto Trait Implementations§
impl Freeze for TokenSpan
impl RefUnwindSafe for TokenSpan
impl Send for TokenSpan
impl Sync for TokenSpan
impl Unpin for TokenSpan
impl UnsafeUnpin for TokenSpan
impl UnwindSafe for TokenSpan
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