pub struct AppendableEncoder<'a> { /* private fields */ }
Expand description
Encoder which keeps track of the encoding length while appending characters.
Implementations§
source§impl<'a> AppendableEncoder<'a>
impl<'a> AppendableEncoder<'a>
pub fn new(bpe: &'a BytePairEncoding) -> AppendableEncoder<'a>
sourcepub fn extend(&mut self, iter: impl Iterator<Item = u8>)
pub fn extend(&mut self, iter: impl Iterator<Item = u8>)
Appends multiple bytes to the input string.
pub fn truncate(&mut self, len: usize)
sourcepub fn push(&mut self, c: u8)
pub fn push(&mut self, c: u8)
Appends a byte to the input string which should be tokenized. The operation is amortized O(1) (due to vector resizing).
sourcepub fn token_count(&self) -> usize
pub fn token_count(&self) -> usize
Returns the number of tokens required to tokenize the input text. This operation is O(1) and can be called at any point in time.
pub fn len(&self) -> usize
Trait Implementations§
source§impl<'a> Clone for AppendableEncoder<'a>
impl<'a> Clone for AppendableEncoder<'a>
source§fn clone(&self) -> AppendableEncoder<'a>
fn clone(&self) -> AppendableEncoder<'a>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<'a> Freeze for AppendableEncoder<'a>
impl<'a> RefUnwindSafe for AppendableEncoder<'a>
impl<'a> Send for AppendableEncoder<'a>
impl<'a> Sync for AppendableEncoder<'a>
impl<'a> Unpin for AppendableEncoder<'a>
impl<'a> UnwindSafe for AppendableEncoder<'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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more