Trait Biplate

Source
pub trait Biplate<To>
where Self: Sized + Clone + Eq + Uniplate + 'static, To: Sized + Clone + Eq + Uniplate + 'static,
{ // 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§

Source

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§

Source

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().

Source

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.

Source

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.

Source

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

Source

fn transform_bi(&self, op: &impl Fn(To) -> To) -> Self

Applies the given function to all nodes bottom up.

Biplate variant of Uniplate::transform

Source

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

Source

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.

Implementations on Foreign Types§

Source§

impl Biplate<Option<i8>> for i8

Source§

fn biplate(&self) -> (Tree<Option<i8>>, Box<dyn Fn(Tree<Option<i8>>) -> i8>)

Source§

impl Biplate<Option<i16>> for i16

Source§

fn biplate(&self) -> (Tree<Option<i16>>, Box<dyn Fn(Tree<Option<i16>>) -> i16>)

Source§

impl Biplate<Option<i32>> for i32

Source§

fn biplate(&self) -> (Tree<Option<i32>>, Box<dyn Fn(Tree<Option<i32>>) -> i32>)

Source§

impl Biplate<Option<i64>> for i64

Source§

fn biplate(&self) -> (Tree<Option<i64>>, Box<dyn Fn(Tree<Option<i64>>) -> i64>)

Source§

impl Biplate<Option<i128>> for i128

Source§

fn biplate( &self, ) -> (Tree<Option<i128>>, Box<dyn Fn(Tree<Option<i128>>) -> i128>)

Source§

impl Biplate<Option<u8>> for u8

Source§

fn biplate(&self) -> (Tree<Option<u8>>, Box<dyn Fn(Tree<Option<u8>>) -> u8>)

Source§

impl Biplate<Option<u16>> for u16

Source§

fn biplate(&self) -> (Tree<Option<u16>>, Box<dyn Fn(Tree<Option<u16>>) -> u16>)

Source§

impl Biplate<Option<u32>> for u32

Source§

fn biplate(&self) -> (Tree<Option<u32>>, Box<dyn Fn(Tree<Option<u32>>) -> u32>)

Source§

impl Biplate<Option<u64>> for u64

Source§

fn biplate(&self) -> (Tree<Option<u64>>, Box<dyn Fn(Tree<Option<u64>>) -> u64>)

Source§

impl Biplate<Option<u128>> for u128

Source§

fn biplate( &self, ) -> (Tree<Option<u128>>, Box<dyn Fn(Tree<Option<u128>>) -> u128>)

Source§

impl Biplate<Option<String>> for String

Source§

fn biplate( &self, ) -> (Tree<Option<String>>, Box<dyn Fn(Tree<Option<String>>) -> String>)

Source§

impl Biplate<i8> for i8

Source§

fn biplate(&self) -> (Tree<i8>, Box<dyn Fn(Tree<i8>) -> i8>)

Source§

impl Biplate<i16> for i16

Source§

fn biplate(&self) -> (Tree<i16>, Box<dyn Fn(Tree<i16>) -> i16>)

Source§

impl Biplate<i32> for i32

Source§

fn biplate(&self) -> (Tree<i32>, Box<dyn Fn(Tree<i32>) -> i32>)

Source§

impl Biplate<i64> for i64

Source§

fn biplate(&self) -> (Tree<i64>, Box<dyn Fn(Tree<i64>) -> i64>)

Source§

impl Biplate<i128> for i128

Source§

fn biplate(&self) -> (Tree<i128>, Box<dyn Fn(Tree<i128>) -> i128>)

Source§

impl Biplate<u8> for u8

Source§

fn biplate(&self) -> (Tree<u8>, Box<dyn Fn(Tree<u8>) -> u8>)

Source§

impl Biplate<u16> for u16

Source§

fn biplate(&self) -> (Tree<u16>, Box<dyn Fn(Tree<u16>) -> u16>)

Source§

impl Biplate<u32> for u32

Source§

fn biplate(&self) -> (Tree<u32>, Box<dyn Fn(Tree<u32>) -> u32>)

Source§

impl Biplate<u64> for u64

Source§

fn biplate(&self) -> (Tree<u64>, Box<dyn Fn(Tree<u64>) -> u64>)

Source§

impl Biplate<u128> for u128

Source§

fn biplate(&self) -> (Tree<u128>, Box<dyn Fn(Tree<u128>) -> u128>)

Source§

impl Biplate<String> for String

Source§

fn biplate(&self) -> (Tree<String>, Box<dyn Fn(Tree<String>) -> String>)

Source§

impl<From, To> Biplate<To> for Option<From>
where To: Uniplate, From: Uniplate + Biplate<Option<From>> + Biplate<To>,

Source§

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

Source§

impl<T, F> Biplate<T> for VecDeque<F>
where T: Clone + Eq + Uniplate + Sized + 'static, F: Clone + Eq + Uniplate + Biplate<T> + Sized + 'static,

Source§

fn biplate(&self) -> (Tree<T>, Box<dyn Fn(Tree<T>) -> VecDeque<F>>)

Source§

impl<T, F> Biplate<T> for Vec<F>
where T: Clone + Eq + Uniplate + Sized + 'static, F: Clone + Eq + Uniplate + Biplate<T> + Sized + 'static,

Source§

fn biplate(&self) -> (Tree<T>, Box<dyn Fn(Tree<T>) -> Vec<F>>)

Implementors§