Skip to main content

ChildList

Struct ChildList 

Source
pub struct ChildList<Id>
where Id: Copy + Default,
{ /* private fields */ }
Expand description

子节点容器:≤3 个孩子零堆分配(AST 绝大多数节点—— Binary/Assign=2、Member/MethodRef=1、VarDecl≤1、Literal=0…… 大语料 malloc 采样的剩余大头是每节点一次 Vec 堆分配); ≥4 溢出到堆。Block/Call 大参数列表溢出属预期路径。

Id 需 Copy + Default(Default 作为空槽哨兵值;语言侧通常用 u32::MAX 之类的非法下标 newtype)。

Implementations§

Source§

impl<Id> ChildList<Id>
where Id: Copy + Default,

Source

pub fn new() -> ChildList<Id>

Source

pub fn from_vec(v: Vec<Id>) -> ChildList<Id>

Source

pub fn as_slice(&self) -> &[Id]

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn set(&mut self, index: usize, new: Id)

按索引替换(保持同一形态)。

Source

pub fn remove(&mut self, index: usize)

移除一个孩子(内联区左移;堆走 Vec::remove)。

Source

pub fn splice(&mut self, index: usize, remove: usize, insert: Vec<Id>)

区间替换(Splice 语义:删 [index, index+remove) 插 insert)。

Trait Implementations§

Source§

impl<Id> Clone for ChildList<Id>
where Id: Clone + Copy + Default,

Source§

fn clone(&self) -> ChildList<Id>

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<Id> Debug for ChildList<Id>
where Id: Debug + Copy + Default,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<Id> Default for ChildList<Id>
where Id: Copy + Default,

Source§

fn default() -> ChildList<Id>

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

impl<Id> PartialEq for ChildList<Id>
where Id: Copy + Default + PartialEq,

Source§

fn eq(&self, other: &ChildList<Id>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<Id> Freeze for ChildList<Id>
where [Id; 3]: Freeze, Vec<Id>: Freeze,

§

impl<Id> RefUnwindSafe for ChildList<Id>

§

impl<Id> Send for ChildList<Id>
where [Id; 3]: Send, Vec<Id>: Send,

§

impl<Id> Sync for ChildList<Id>
where [Id; 3]: Sync, Vec<Id>: Sync,

§

impl<Id> Unpin for ChildList<Id>
where [Id; 3]: Unpin, Vec<Id>: Unpin,

§

impl<Id> UnsafeUnpin for ChildList<Id>

§

impl<Id> UnwindSafe for ChildList<Id>

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