Skip to main content

Arena

Struct Arena 

Source
pub struct Arena {
    pub nodes: Vec<Node>,
    pub kids: Vec<u32>,
    pub ext: Vec<Vec<u8>>,
    pub ext_map: HashMap<Vec<u8>, u32>,
    pub ext_total: usize,
}

Fields§

§nodes: Vec<Node>§kids: Vec<u32>§ext: Vec<Vec<u8>>

去重后的扫描器状态;编号 0 固定表示空状态,编号 i>0 对应 ext[i-1]。

§ext_map: HashMap<Vec<u8>, u32>§ext_total: usize

Implementations§

Source§

impl Arena

Source

pub fn n(&self, i: u32) -> &Node

Source

pub fn n_mut(&mut self, i: u32) -> &mut Node

Source

pub fn intern_ext(&mut self, bytes: &[u8]) -> u32

登记一份扫描器状态,相同内容共用同一个编号。

Source

pub fn ext_bytes(&self, i: u32) -> &[u8] ⓘ

Source

pub fn children(&self, i: u32) -> &[u32]

Source

pub fn new_leaf( &mut self, lang: &Language, sym: u16, padding: Len, size: Len, ) -> u32

Source

pub fn new_missing_leaf(&mut self, lang: &Language, sym: u16) -> u32

Source

pub fn new_node( &mut self, lang: &Language, sym: u16, children: &[u32], prod: u16, ) -> u32

官方 ts_subtree_new_node + summarize_children。

Source

pub fn new_error_node( &mut self, lang: &Language, children: &[u32], extra: bool, ) -> u32

Source

pub fn compare(&self, a: u32, b: u32) -> i32

官方 ts_subtree_compare:按符号、子节点数逐个比较,返回 -1/0/1。

Trait Implementations§

Source§

impl Default for Arena

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for Arena

§

impl Freeze for Arena

§

impl Move for Arena

§

impl RefUnwindSafe for Arena

§

impl Send for Arena

§

impl Sync for Arena

§

impl Unpin for Arena

§

impl UnsafeUnpin for Arena

§

impl UnwindSafe for Arena

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> 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, 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.