Trait uniplate::biplate::Uniplate

source ·
pub trait Uniplate
where Self: Sized + Clone + Eq + 'static,
{ // Required method fn uniplate(&self) -> (Tree<Self>, Box<dyn Fn(Tree<Self>) -> Self>); // Provided methods fn descend(&self, op: Arc<dyn Fn(Self) -> Self>) -> Self { ... } fn universe(&self) -> Vector<Self> { ... } fn children(&self) -> Vector<Self> { ... } fn with_children(&self, children: Vector<Self>) -> Self { ... } fn transform(&self, f: Arc<dyn Fn(Self) -> Self>) -> Self { ... } fn rewrite(&self, f: Arc<dyn Fn(Self) -> Option<Self>>) -> Self { ... } fn cata<T>(&self, op: Arc<dyn Fn(Self, Vec<T>) -> T>) -> T { ... } }

Required Methods§

source

fn uniplate(&self) -> (Tree<Self>, Box<dyn Fn(Tree<Self>) -> Self>)

Provided Methods§

source

fn descend(&self, op: Arc<dyn Fn(Self) -> Self>) -> Self

source

fn universe(&self) -> Vector<Self>

Gest all children of a node, including itself and all children.

source

fn children(&self) -> Vector<Self>

Gets the direct children (maximal substructures) of a node.

source

fn with_children(&self, children: Vector<Self>) -> Self

Reconstructs the node with the given children.

§Panics

If there are a different number of children given as there were originally returned by children().

source

fn transform(&self, f: Arc<dyn Fn(Self) -> Self>) -> Self

Applies the given rule to all nodes bottom up.

source

fn rewrite(&self, f: Arc<dyn Fn(Self) -> Option<Self>>) -> Self

Rewrites by applying a rule everywhere it can.

source

fn cata<T>(&self, op: Arc<dyn Fn(Self, Vec<T>) -> T>) -> T

Performs a fold-like computation on each value.

Working from the bottom up, this applies the given callback function to each nested component.

Unlike transform, this returns an arbitrary type, and is not limited to T -> T transformations. In other words, it can transform a type into a new one.

The meaning of the callback function is the following:

f(element_to_fold, folded_children) -> folded_element

Object Safety§

This trait is not object safe.

Implementors§