macro_rules! unpack_named_slots { ($map:expr => $name:ident) => { ... }; ($map:expr => { $($name:ident),+ }) => { ... }; }
Expand description
A helper for getting the named children out of a widget context
ยงExample
fn my_component(context: WidgetContext) -> WidgetNode {
// Destructure our context to get our named slots
let WidgetContext {
named_slots,
..
} = context;
// Unpack our named `body` slot
unpack_named_slots!(named_slots => body);
make_widget!(content_box).named_slot("content", body).into()
}
You can also unpack multiple slots at a time like this:
// Unpack the `header`, `body`, and `footer` slots
unpack_named_slots!(named_slots => { header, body, footer });