Trait TreeNodeRefContainer

Source
pub trait TreeNodeRefContainer<'a, T: 'a>: Sized {
    // Required method
    fn apply_ref_elements<F: FnMut(&'a T) -> Result<TreeNodeRecursion>>(
        &self,
        f: F,
    ) -> Result<TreeNodeRecursion>;
}
Expand description

TreeNodeRefContainer contains references to elements that a function can be applied on. The elements of the container are siblings so the continuation rules are similar to TreeNodeRecursion::visit_sibling.

This container is similar to TreeNodeContainer, but the lifetime of the reference elements (T) are not derived from the container’s lifetime. A typical usage of this container is in Expr::apply_children when we need to construct a temporary container to be able to call apply_ref_elements on a collection of tree node references. But in that case the container’s temporary lifetime is different to the lifetime of tree nodes that we put into it. Please find an example use case in Expr::apply_children with the Expr::Case case.

Most of the cases we don’t need to create a temporary container with TreeNodeRefContainer, but we can just call TreeNodeContainer::apply_elements. Please find an example use case in Expr::apply_children with the Expr::GroupingSet case.

Required Methods§

Source

fn apply_ref_elements<F: FnMut(&'a T) -> Result<TreeNodeRecursion>>( &self, f: F, ) -> Result<TreeNodeRecursion>

Applies f to all elements of the container. This method is usually called from TreeNode::apply_children implementations as a node is actually a container of the node’s children.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a, T: 'a, C0: TreeNodeContainer<'a, T>, C1: TreeNodeContainer<'a, T>> TreeNodeRefContainer<'a, T> for (&'a C0, &'a C1)

Source§

impl<'a, T: 'a, C0: TreeNodeContainer<'a, T>, C1: TreeNodeContainer<'a, T>, C2: TreeNodeContainer<'a, T>> TreeNodeRefContainer<'a, T> for (&'a C0, &'a C1, &'a C2)

Source§

impl<'a, T: 'a, C: TreeNodeContainer<'a, T>> TreeNodeRefContainer<'a, T> for Vec<&'a C>

Implementors§