pub struct MergeTable { /* private fields */ }Expand description
Maps an adjacent (left_id, right_id) pair to its MergeRule.
Implementations§
Source§impl MergeTable
impl MergeTable
Sourcepub fn build(
merges: &[(Vec<u8>, Vec<u8>)],
lookup: impl FnMut(&[u8]) -> Option<u32>,
) -> Result<Self>
pub fn build( merges: &[(Vec<u8>, Vec<u8>)], lookup: impl FnMut(&[u8]) -> Option<u32>, ) -> Result<Self>
Builds a merge table from an ordered list of (left_bytes, right_bytes) pairs, resolving each side and the concatenated
result to vocab ids via lookup.
lookup is a closure rather than a &Vocab borrow so this stays
decoupled from crate::vocab::Vocab’s concrete type – the only
thing a merge table needs from a vocab is “what id is this byte
string?”.
Sourcepub fn get(&self, left_id: u32, right_id: u32) -> Option<MergeRule>
pub fn get(&self, left_id: u32, right_id: u32) -> Option<MergeRule>
The merge rule for an adjacent pair, if the pair has one.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Clone for MergeTable
impl Clone for MergeTable
Source§fn clone(&self) -> MergeTable
fn clone(&self) -> MergeTable
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MergeTable
impl Debug for MergeTable
Source§impl Default for MergeTable
impl Default for MergeTable
Source§fn default() -> MergeTable
fn default() -> MergeTable
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MergeTable
impl RefUnwindSafe for MergeTable
impl Send for MergeTable
impl Sync for MergeTable
impl Unpin for MergeTable
impl UnsafeUnpin for MergeTable
impl UnwindSafe for MergeTable
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