Skip to main content

Module child

Module child 

Source
Expand description

A child protocol with the inbox its indications are collected into.

Every composing protocol did the same eleven lines per child: take the inbox out of self, borrow the child, call Cx::with_child_consuming, drain what was collected, put the inbox back. Constraint 4 in CLAUDE.md said to write that by hand two or three times before removing it; there were sixteen copies when this was written. This is the removal, and it is a struct rather than a macro so that the control flow stays in the parent’s own text.

The inbox is handed back by value rather than drained here, because the parent handles a child’s indications with &mut self — including, sometimes, by calling run again on the same or another child — and a borrow held across that would not compile. Child::reclaim puts the allocation back so it is reused across events, which is what tests/alloc_probe.rs measures.

Structs§

Child
A protocol owned by another, with the inbox its indications are collected into.