Function recursion::stack_machine::expand_and_collapse
source · [−]pub fn expand_and_collapse<Seed, Out, Expandable, Collapsable>(
seed: Seed,
expand_layer: impl FnMut(Seed) -> Expandable,
collapse_layer: impl FnMut(Collapsable) -> Out
) -> Outwhere
Expandable: MapLayer<(), Unwrapped = Seed>,
<Expandable as MapLayer<()>>::To: MapLayer<Out, Unwrapped = (), To = Collapsable>,
Expand description
Build a state machine by simultaneously expanding a seed into some structure and consuming that structure from the leaves down
Type parameter explanation:
Layer: some partially applied type, eg Option or Vec. Not yet representable in Rust.
Seed: the initial value that structure is expanded out from
Out: the value that the structure is collapsed into
Expandable: a single layer of expanding structure, of type Layer