Skip to main content

CodeTable

Struct CodeTable 

Source
pub struct CodeTable { /* private fields */ }
Expand description

A table of per-character codes with a default function.

Storage is a two-level page table: 256-character pages, allocated on first assignment and filled with the defaults. Lookups are two array indexings, with no hashing, which matters because the scanner consults these tables for every character.

Implementations§

Source§

impl CodeTable

Source

pub fn new(default: fn(u32) -> i64) -> Self

A table where every character has value default(c).

Source

pub fn get(&self, c: u32) -> i64

The value for c.

Source

pub fn level(&self, c: u32) -> u16

The level of the definition for c.

Source

pub fn define_in_place(&mut self, c: u32, val: i64, cur: u16) -> bool

Assigns val to c at level cur when that needs no save-stack entry (the value is unchanged, or was defined at level cur, or cur is level one). Returns false, changing nothing, otherwise.

Source

pub fn set(&mut self, c: u32, val: i64, level: u16)

Sets value and level for c.

Source

pub fn default_fn(&self) -> fn(u32) -> i64

The default function of this table.

Source

pub fn dump_pages(&self) -> Vec<(usize, [i64; 256])>

The values of every allocated page that differs from the defaults, as (page number, values), for format dumping.

Source

pub fn load_page(&mut self, k: usize, page: Rc<Page>)

Installs a page (format loading); the page may be shared.

Source

pub fn explicit(&self) -> impl Iterator<Item = (u32, i64, u16)> + '_

Iterates, in code-point order, over the characters of all allocated pages: the first 256 characters and every page containing an assignment.

Trait Implementations§

Source§

impl Clone for CodeTable

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CodeTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.