Skip to main content

ReduceCx

Struct ReduceCx 

pub struct ReduceCx<'a> { /* private fields */ }
Expand description

The arena/token context handed to a ReduceCallback::reduce call. Both engines build one over their live child arena + token arena, so the hook resolves NodeValue::Token(idx) leaves and constructs arena-backed NodeValue::Trees (the representation a _-splice parent can drain) without engine-specific glue.

Implementations§

§

impl<'a> ReduceCx<'a>

pub fn new( arena: &'a mut Vec<NodeValue>, tokens: &'a [Token], metas: &'a [Meta], ) -> Self

pub fn take_span_plan(&mut self) -> Option<PendingSpan>

The reduce’s RAW pre-filter span plan — Some only under propagate_positions in transform mode. A batching hook takes it at enqueue and resolves/stamps at its drain (lark’s PropagatePositions semantics); leaving it means the engine stamps the returned value itself (Tree results only).

pub fn token(&self, idx: TokenArenaIdx) -> &Token

Resolve a NodeValue::Token(idx) leaf to its Token (a binding materializes its host token type from this). idx/tree here (and in Self::tree_children/Self::tree_meta) must come from an engine-produced NodeValue; an out-of-range index panics — engine- invariant, the same tier as the ParsedTree accessors.

pub fn tree_children(&self, tree: &Tree) -> &[NodeValue]

Read a NodeValue::Tree’s children out of the arena (a binding walks a sub-result it did not itself build).

pub fn tree_meta(&self, tree: &Tree) -> Option<&Meta>

A Tree’s position Meta, when one was computed (propagate_positions on and the node stamped). None for MetaIdx::NONE.

pub fn build_tree( &mut self, data_id: DisplayId, children: Vec<NodeValue>, ) -> NodeValue

Build an arena-backed Tree(data_id, children) (meta == MetaIdx::NONE; the engine attaches position meta to the returned node afterward under propagate_positions). This is the drainable default a _-splice parent inlines via child.children.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ReduceCx<'a>

§

impl<'a> !UnwindSafe for ReduceCx<'a>

§

impl<'a> Freeze for ReduceCx<'a>

§

impl<'a> Send for ReduceCx<'a>

§

impl<'a> Sync for ReduceCx<'a>

§

impl<'a> Unpin for ReduceCx<'a>

§

impl<'a> UnsafeUnpin for ReduceCx<'a>

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, <T as TryFrom<U>>::Error>

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.