uniplate

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: Vector<To>) -> Self { ... } fn descend_bi(&self, op: Arc<dyn Fn(To) -> To>) -> Self { ... } fn universe_bi(&self) -> Vector<To> { ... } fn children_bi(&self) -> Vector<To> { ... } fn transform_bi(&self, op: Arc<dyn Fn(To) -> To>) -> Self { ... } fn holes_bi(&self) -> impl Iterator<Item = (To, Arc<dyn Fn(To) -> Self>)> { ... } fn contexts_bi(&self) -> impl Iterator<Item = (To, Arc<dyn Fn(To) -> Self>)> { ... } }
Expand description

Biplate<U> for type T operates over all values of type U within T.

Required Methods§

Source

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

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: Vector<To>) -> 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 descend_bi(&self, op: Arc<dyn Fn(To) -> To>) -> Self

Like descend but with more general types.

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 descendBi, then continue the recursion with descend.

Source

fn universe_bi(&self) -> Vector<To>

Source

fn children_bi(&self) -> Vector<To>

Returns the children of a type. If to == from then it returns the original element (in contrast to children).

Source

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

Source

fn holes_bi(&self) -> impl Iterator<Item = (To, Arc<dyn 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.

Source

fn contexts_bi(&self) -> impl Iterator<Item = (To, Arc<dyn Fn(To) -> Self>)>

holes_bi, but for universe()

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

Source§

impl<T, F> Biplate<T> for Vector<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>) -> Vector<F>>)

Implementors§