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§
Object Safety§
This trait is not object safe.