pub trait Uniplate{
// 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 { ... }
fn holes(&self) -> impl Iterator<Item = (Self, Arc<dyn Fn(Self) -> Self>)> { ... }
fn contexts(
&self,
) -> impl Iterator<Item = (Self, Arc<dyn Fn(Self) -> Self>)> { ... }
}Expand description
Uniplate for type T operates over all values of type T within T.
Required Methods§
Provided Methods§
fn descend(&self, op: Arc<dyn Fn(Self) -> Self>) -> Self
Sourcefn universe(&self) -> Vector<Self>
fn universe(&self) -> Vector<Self>
Gets all children of a node, including itself and all children.
Sourcefn with_children(&self, children: Vector<Self>) -> Self
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().
Sourcefn transform(&self, f: Arc<dyn Fn(Self) -> Self>) -> Self
fn transform(&self, f: Arc<dyn Fn(Self) -> Self>) -> Self
Applies the given rule to all nodes bottom up.
Sourcefn rewrite(&self, f: Arc<dyn Fn(Self) -> Option<Self>>) -> Self
fn rewrite(&self, f: Arc<dyn Fn(Self) -> Option<Self>>) -> Self
Rewrites by applying a rule everywhere it can.
Sourcefn cata<T>(&self, op: Arc<dyn Fn(Self, Vec<T>) -> T>) -> T
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
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.