Skip to main content

TakeIn

Trait TakeIn 

Source
pub trait TakeIn<'a>: Dummy<'a> {
    // Provided methods
    fn take_in(&mut self, allocator_accessor: &impl GetAllocator<'a>) -> Self { ... }
    fn take_in_box(
        &mut self,
        allocator_accessor: &impl GetAllocator<'a>,
    ) -> Box<'a, Self> { ... }
}
Expand description

A trait to replace an existing AST node with a dummy.

Provided Methods§

Source

fn take_in(&mut self, allocator_accessor: &impl GetAllocator<'a>) -> Self

Replace node with a dummy, and return the original.

If you’re taking the node out to build a new node from it and store the result back in the same slot, prefer replace_with. take_in writes a dummy into the arena, which takes up space there forever. replace_with avoids that (no dummy), so is faster and uses less memory.

Source

fn take_in_box( &mut self, allocator_accessor: &impl GetAllocator<'a>, ) -> Box<'a, Self>

Replace node with a dummy, allocate the original node into the arena, and return it as a Box<Self>.

If you’re taking the node out to build a new node from it and store the result back in the same slot, prefer replace_with. take_in writes a dummy into the arena, which takes up space there forever. replace_with avoids that (no dummy), so is faster and uses less memory.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a, T> TakeIn<'a> for Box<'a, [T]>

Source§

impl<'a, T> TakeIn<'a> for Vec<'a, T>