Struct TokenSlice
struct TokenSlice<'t, T> { ... }
Specialized input for parsing lexed tokens
Helpful impls
- Any
PartialEqtype (e.g. aTokenKindor&str) can be used with [literal][crate::token::literal] - A
PartialEqfor&strallows for using&stras a parser for tokens - [
ContainsToken][crate::stream::ContainsToken] forTto for parsing with token sets LocationforTto extract spans from tokens
See also [Lexing and Parsing][crate::_topic::lexing].
Implementations
impl<'t, T> TokenSlice<'t, T>
fn new(input: &'t [T]) -> SelfMake a stream to parse tokens
fn reset_to_start(self: &mut Self)Reset the stream to the start
This is useful for formats that encode a graph with addresses relative to the start of the input.
fn previous_tokens(self: &Self) -> impl Iterator<Item = &'t T>Iterate over consumed tokens starting with the last emitted
This is intended to help build up appropriate context when reporting errors.
impl<'t, T> Freeze for TokenSlice<'t, T>
impl<'t, T> RefUnwindSafe for TokenSlice<'t, T>
impl<'t, T> Send for TokenSlice<'t, T>
impl<'t, T> Stream for TokenSlice<'t, T>
fn iter_offsets(self: &Self) -> <Self as >::IterOffsetsfn eof_offset(self: &Self) -> usizefn next_token(self: &mut Self) -> Option<<Self as >::Token>fn peek_token(self: &Self) -> Option<<Self as >::Token>fn offset_for<P>(self: &Self, predicate: P) -> Option<usize> where P: Fn(<Self as >::Token) -> boolfn offset_at(self: &Self, tokens: usize) -> Result<usize, Needed>fn next_slice(self: &mut Self, offset: usize) -> <Self as >::Sliceunsafe fn next_slice_unchecked(self: &mut Self, offset: usize) -> <Self as >::Slicefn peek_slice(self: &Self, offset: usize) -> <Self as >::Sliceunsafe fn peek_slice_unchecked(self: &Self, offset: usize) -> <Self as >::Slicefn checkpoint(self: &Self) -> <Self as >::Checkpointfn reset(self: &mut Self, checkpoint: &<Self as >::Checkpoint)fn raw(self: &Self) -> &dyn Debugfn trace(self: &Self, f: &mut Formatter<'_>) -> Result
impl<'t, T> StreamIsPartial for TokenSlice<'t, T>
fn complete(self: &mut Self) -> <Self as >::PartialStatefn restore_partial(self: &mut Self, state: <Self as >::PartialState)fn is_partial_supported() -> boolfn is_partial(self: &Self) -> bool
impl<'t, T> StructuralPartialEq for TokenSlice<'t, T>
impl<'t, T> Sync for TokenSlice<'t, T>
impl<'t, T> Unpin for TokenSlice<'t, T>
impl<'t, T> UnsafeUnpin for TokenSlice<'t, T>
impl<'t, T> UnwindSafe for TokenSlice<'t, T>
impl<'t, T: $crate::clone::Clone> Clone for TokenSlice<'t, T>
fn clone(self: &Self) -> TokenSlice<'t, T>
impl<'t, T: $crate::cmp::Eq> Eq for TokenSlice<'t, T>
impl<'t, T: $crate::cmp::PartialEq> PartialEq for TokenSlice<'t, T>
fn eq(self: &Self, other: &TokenSlice<'t, T>) -> bool
impl<'t, T: $crate::marker::Copy> Copy for TokenSlice<'t, T>
impl<P, T> Receiver for TokenSlice<'t, T>
impl<T> Any for TokenSlice<'t, T>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for TokenSlice<'t, T>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for TokenSlice<'t, T>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for TokenSlice<'t, T>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> Default for TokenSlice<'_, T>
fn default() -> Self
impl<T> Deref for TokenSlice<'_, T>
fn deref(self: &Self) -> &<Self as >::Target
impl<T> From for TokenSlice<'t, T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Location for TokenSlice<'_, T>
fn previous_token_end(self: &Self) -> usizefn current_token_start(self: &Self) -> usize
impl<T> Offset for TokenSlice<'_, T>
fn offset_from(self: &Self, other: &Self) -> usize
impl<T> Offset for TokenSlice<'_, T>
fn offset_from(self: &Self, other: &<TokenSlice<'_, T> as Stream>::Checkpoint) -> usize
impl<T> SliceLen for TokenSlice<'_, T>
fn slice_len(self: &Self) -> usize
impl<T> UpdateSlice for TokenSlice<'_, T>
fn update_slice(self: Self, inner: <Self as >::Slice) -> Self
impl<T, O> Compare for TokenSlice<'_, T>
fn compare(self: &Self, t: O) -> CompareResult
impl<T, U> Into for TokenSlice<'t, T>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for TokenSlice<'t, T>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for TokenSlice<'t, T>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T: core::fmt::Debug> Debug for TokenSlice<'_, T>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result