pub trait Biplate<To>{
// Required method
fn biplate(&self) -> (Tree<To>, Box<dyn Fn(Tree<To>) -> Self>);
// Provided methods
fn with_children_bi(&self, children: VecDeque<To>) -> Self { ... }
fn descend_bi(&self, op: &impl Fn(To) -> To) -> Self { ... }
fn universe_bi(&self) -> VecDeque<To> { ... }
fn children_bi(&self) -> VecDeque<To> { ... }
fn transform_bi(&self, op: &impl Fn(To) -> To) -> Self { ... }
fn holes_bi(&self) -> impl Iterator<Item = (To, impl Fn(To) -> Self)> { ... }
fn contexts_bi(&self) -> impl Iterator<Item = (To, impl Fn(To) -> Self)> { ... }
}Expand description
Biplate<U> for type T operates over all values of type U within T.
Note: Biplate<T> for T returns the input expression, not its children of type T. Use
Uniplate instead.
Required Methods§
Sourcefn biplate(&self) -> (Tree<To>, Box<dyn Fn(Tree<To>) -> Self>)
fn biplate(&self) -> (Tree<To>, Box<dyn Fn(Tree<To>) -> Self>)
Definition of a Biplate.
This is a low-level method useful only for implementing the Biplate trait.
Returns all the top most children of type To within From.
If from == to then this function should return the root as the single child.
Provided Methods§
Sourcefn with_children_bi(&self, children: VecDeque<To>) -> Self
fn with_children_bi(&self, children: VecDeque<To>) -> Self
Reconstructs the node with the given children.
Biplate variant of Uniplate::children
§Panics
If there are a different number of children given as there were originally returned by children().
Sourcefn descend_bi(&self, op: &impl Fn(To) -> To) -> Self
fn descend_bi(&self, op: &impl Fn(To) -> To) -> Self
Biplate variant of Uniplate::descend
If from == to then this function does not descend. Therefore, when writing definitions it is highly unlikely that this function should be used in the recursive case. A common pattern is to first match the types using descend_bi, then continue the recursion with descend.
Sourcefn universe_bi(&self) -> VecDeque<To>
fn universe_bi(&self) -> VecDeque<To>
Gets all children of a node, including itself and all children.
Biplate variant of Uniplate::universe
Universe_bi does a preorder traversal: it returns a given node first, followed by its children from left to right.
If to == from then it returns the original element.
Sourcefn children_bi(&self) -> VecDeque<To>
fn children_bi(&self) -> VecDeque<To>
Returns the children of a type. If to == from then it returns the original element (in contrast to children).
Biplate variant of Uniplate::children
Sourcefn transform_bi(&self, op: &impl Fn(To) -> To) -> Self
fn transform_bi(&self, op: &impl Fn(To) -> To) -> Self
Applies the given function to all nodes bottom up.
Biplate variant of Uniplate::transform
Sourcefn holes_bi(&self) -> impl Iterator<Item = (To, impl Fn(To) -> Self)>
fn holes_bi(&self) -> impl Iterator<Item = (To, impl Fn(To) -> Self)>
Returns an iterator over all direct children of the input, paired with a function that “fills the hole” where the child was with a new value.
Biplate variant of Uniplate::holes
Sourcefn contexts_bi(&self) -> impl Iterator<Item = (To, impl Fn(To) -> Self)>
fn contexts_bi(&self) -> impl Iterator<Item = (To, impl Fn(To) -> Self)>
Returns an iterator over the universe of the input, paired with a function that “fills the hole” where the child was with a new value.
Biplate variant of Uniplate::contexts
To efficiently update multiple values in a single traversal, use
ZipperBi instead.
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.