risingwave_frontend::utils

Trait Layer

source
pub trait Layer: Sized {
    type Sub;

    // Required methods
    fn map<F>(self, f: F) -> Self
       where F: FnMut(Self::Sub) -> Self::Sub;
    fn descent<F>(&self, f: F)
       where F: FnMut(&Self::Sub);
}
Expand description

A Layer is a container with subcomponents of type Sub. We usually use Layer to represents one layer of a tree-like structure, where the subcomponents are the recursive subtrees. But in general, the subcomponent can be of different type than the Layer. Such structural relation between Sub and Layer allows us to lift transformation on Sub to that on Layer. A related and even more general notion is Functor, which might also be helpful to define in the future.

Required Associated Types§

Required Methods§

source

fn map<F>(self, f: F) -> Self
where F: FnMut(Self::Sub) -> Self::Sub,

Given a transformation f : Sub -> Sub, we can derive a transformation on the entire Layer by acting f on all subcomponents.

source

fn descent<F>(&self, f: F)
where F: FnMut(&Self::Sub),

Given a traversal f : Sub -> (), we can derive a traversal on the entire Layer by sequentially visiting the subcomponents with f.

Object Safety§

This trait is not object safe.

Implementors§