Struct LocatingSlice
struct LocatingSlice<I> { ... }
Allow collecting the span of a parsed token within a slice
Converting byte offsets to line or column numbers is left up to the user, as computing column numbers requires domain knowledge (are columns byte-based, codepoint-based, or grapheme-based?) and O(n) iteration over the input to determine codepoint and line boundaries.
The line-span crate can help with converting
byte offsets to line numbers.
See [Parser::span][crate::Parser::span] and [Parser::with_span][crate::Parser::with_span] for more details
Implementations
impl<I> LocatingSlice<I>
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.
impl<I> LocatingSlice<I>
fn new(input: I) -> SelfWrap another Stream with span tracking
impl<I> AsBStr for LocatingSlice<I>
fn as_bstr(self: &Self) -> &[u8]
impl<I> AsBytes for LocatingSlice<I>
fn as_bytes(self: &Self) -> &[u8]
impl<I> AsRef for LocatingSlice<I>
fn as_ref(self: &Self) -> &I
impl<I> Deref for LocatingSlice<I>
fn deref(self: &Self) -> &<Self as >::Target
impl<I> Freeze for LocatingSlice<I>
impl<I> Location for LocatingSlice<I>
fn previous_token_end(self: &Self) -> usizefn current_token_start(self: &Self) -> usize
impl<I> Offset for LocatingSlice<I>
fn offset_from(self: &Self, other: &<LocatingSlice<I> as Stream>::Checkpoint) -> usize
impl<I> Offset for LocatingSlice<I>
fn offset_from(self: &Self, other: &Self) -> usize
impl<I> RefUnwindSafe for LocatingSlice<I>
impl<I> Send for LocatingSlice<I>
impl<I> SliceLen for LocatingSlice<I>
fn slice_len(self: &Self) -> usize
impl<I> StreamIsPartial for LocatingSlice<I>
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<I> StructuralPartialEq for LocatingSlice<I>
impl<I> Sync for LocatingSlice<I>
impl<I> Unpin for LocatingSlice<I>
impl<I> UnsafeUnpin for LocatingSlice<I>
impl<I> UnwindSafe for LocatingSlice<I>
impl<I> UpdateSlice for LocatingSlice<I>
fn update_slice(self: Self, inner: <Self as >::Slice) -> Self
impl<I, T> FindSlice for LocatingSlice<I>
fn find_slice(self: &Self, substr: T) -> Option<Range<usize>>
impl<I, U> Compare for LocatingSlice<I>
fn compare(self: &Self, other: U) -> CompareResult
impl<I: $crate::clone::Clone> Clone for LocatingSlice<I>
fn clone(self: &Self) -> LocatingSlice<I>
impl<I: $crate::cmp::Eq> Eq for LocatingSlice<I>
impl<I: $crate::cmp::Ord> Ord for LocatingSlice<I>
fn cmp(self: &Self, other: &LocatingSlice<I>) -> Ordering
impl<I: $crate::cmp::PartialEq> PartialEq for LocatingSlice<I>
fn eq(self: &Self, other: &LocatingSlice<I>) -> bool
impl<I: $crate::cmp::PartialOrd> PartialOrd for LocatingSlice<I>
fn partial_cmp(self: &Self, other: &LocatingSlice<I>) -> Option<Ordering>
impl<I: $crate::default::Default> Default for LocatingSlice<I>
fn default() -> LocatingSlice<I>
impl<I: $crate::marker::Copy> Copy for LocatingSlice<I>
impl<I: Stream> Stream for LocatingSlice<I>
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<I: core::fmt::Debug> Debug for LocatingSlice<I>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<I: crate::lib::std::fmt::Display> Display for LocatingSlice<I>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<P, T> Receiver for LocatingSlice<I>
impl<T> Any for LocatingSlice<I>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for LocatingSlice<I>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for LocatingSlice<I>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for LocatingSlice<I>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for LocatingSlice<I>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for LocatingSlice<I>
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 LocatingSlice<I>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for LocatingSlice<I>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>