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§
Sourcefn apply_ref_elements<F: FnMut(&'a T) -> Result<TreeNodeRecursion>>(
&self,
f: F,
) -> Result<TreeNodeRecursion>
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.