pub struct Tokenization<'a> { /* private fields */ }
Expand description
A tokenized slice of bytes.
Implementations§
Source§impl<'a> Tokenization<'a>
impl<'a> Tokenization<'a>
pub fn new(data: &'a [u8], tokens: &'a [HashedSpan]) -> Self
pub fn data(&self) -> &'a [u8] ⓘ
Sourcepub fn split_at(&self, lo: isize, hi: isize) -> (Self, Self)
pub fn split_at(&self, lo: isize, hi: isize) -> (Self, Self)
Split self
in two tokenizations:
- the first one from the start to
lo
; - the second one from
hi
to the end.
Sourcepub fn nth_token(&self, n: isize) -> HashedSlice<'_>
pub fn nth_token(&self, n: isize) -> HashedSlice<'_>
Get self
’s n
th token.
Sourcepub fn nth_span(&self, n: isize) -> HashedSpan
pub fn nth_span(&self, n: isize) -> HashedSpan
Get the span corresponding to self
’s n
th token.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Tokenization<'a>
impl<'a> RefUnwindSafe for Tokenization<'a>
impl<'a> Send for Tokenization<'a>
impl<'a> Sync for Tokenization<'a>
impl<'a> Unpin for Tokenization<'a>
impl<'a> UnwindSafe for Tokenization<'a>
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