pub struct Slots { /* private fields */ }Expand description
The children a component receives from its call site, grouped by slot. A bare child lands in the
default slot (None); a child written with slot:"name" lands in that named slot. Inside the
component, the children placeholder drains the default slot and children name:"x" drains the
"x" slot — each in call-site order. Draining is one-shot: a slot placeholder consumes its
children, so referencing the same slot twice yields an empty list the second time.
Implementations§
Source§impl Slots
impl Slots
pub fn new() -> Self
pub fn push(&mut self, name: Option<&'static str>, item: Box<dyn LayoutItem>)
Sourcepub fn extend_default(
&mut self,
items: impl IntoIterator<Item = Box<dyn LayoutItem>>,
)
pub fn extend_default( &mut self, items: impl IntoIterator<Item = Box<dyn LayoutItem>>, )
Appends items as default (unnamed) children. What every generated component call site does with the
children it collected, so the emitter writes one call instead of a hand-rolled loop 418 times over.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the call site passed no children at all — what a compound component checks before falling back to whatever it shows when it was given nothing.
Sourcepub fn take_default(&mut self) -> Vec<Box<dyn LayoutItem>>
pub fn take_default(&mut self) -> Vec<Box<dyn LayoutItem>>
Drains the default (unnamed) children in call-site order.