Skip to main content

Edit

Enum Edit 

Source
pub enum Edit<L: Lang> {
    Replace {
        target: L::Id,
        with: L::Id,
    },
    Delete {
        node: L::Id,
    },
    Splice {
        node: L::Id,
        index: usize,
        remove: usize,
        insert: Vec<L::Id>,
    },
    Multi(Vec<Edit<L>>),
}
Expand description

一次结构编辑提案。

Variants§

§

Replace

用 with 子树替换 target 节点(target 必须有父节点)。

Fields

§target: L::Id
§with: L::Id
§

Delete

删除一个节点(其父从 children 中移除该槽位)。

Fields

§node: L::Id
§

Splice

对 node 自身的 children 做切片编辑。

Fields

§node: L::Id
§index: usize
§remove: usize
§insert: Vec<L::Id>
§

Multi(Vec<Edit<L>>)

多个编辑按序原子应用。 约束:前面的编辑不得使后面编辑的 (parent, index) 失效—— 先替换靠后的节点、后删除靠前的节点是安全顺序。

Implementations§

Source§

impl<L: Lang> Edit<L>

Source

pub fn cost_reduction(&self, lang: &mut L) -> u64

应用本编辑会带来的成本降幅(严格 > 0 才允许生效)。

Trait Implementations§

Source§

impl<L: Debug + Lang> Debug for Edit<L>
where L::Id: Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<L> Freeze for Edit<L>
where <L as Lang>::Id: Freeze, Vec<<L as Lang>::Id>: Freeze, Vec<Edit<L>>: Freeze,

§

impl<L> RefUnwindSafe for Edit<L>
where <L as Lang>::Id: RefUnwindSafe, Vec<<L as Lang>::Id>: RefUnwindSafe, Vec<Edit<L>>: RefUnwindSafe,

§

impl<L> Send for Edit<L>
where <L as Lang>::Id: Send, Vec<<L as Lang>::Id>: Send, Vec<Edit<L>>: Send,

§

impl<L> Sync for Edit<L>
where <L as Lang>::Id: Sync, Vec<<L as Lang>::Id>: Sync, Vec<Edit<L>>: Sync,

§

impl<L> Unpin for Edit<L>
where <L as Lang>::Id: Unpin, Vec<<L as Lang>::Id>: Unpin, Vec<Edit<L>>: Unpin,

§

impl<L> UnsafeUnpin for Edit<L>
where <L as Lang>::Id: UnsafeUnpin, Vec<<L as Lang>::Id>: UnsafeUnpin, Vec<Edit<L>>: UnsafeUnpin,

§

impl<L> UnwindSafe for Edit<L>
where <L as Lang>::Id: UnwindSafe, Vec<<L as Lang>::Id>: UnwindSafe, Vec<Edit<L>>: UnwindSafe,

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.