pub trait EntitySlotExt<T>where
T: 'static,{
// Required method
fn slot<F, E>(
&self,
id: impl Into<ElementId>,
builder: F,
) -> SlotElement<T, F>
where F: Fn(&T, &mut Window<'_>, &mut Context<'_, T>) -> E + 'static,
E: IntoElement + 'static;
}Expand description
Renders an Entity through a closure instead of a Render
implementation.
Entity::cached gets the same reuse for types that implement
Render. This is for state that has no renderer of its own,
or that is rendered differently in different places.
Required Methods§
Sourcefn slot<F, E>(&self, id: impl Into<ElementId>, builder: F) -> SlotElement<T, F>
fn slot<F, E>(&self, id: impl Into<ElementId>, builder: F) -> SlotElement<T, F>
Renders this entity’s state through builder, reusing the subtree it
produces until the entity is notified.
id identifies the slot, and becomes the root of the element id space the
subtree’s internal state lives in, so an entity rendered twice in
different places needs a slot id per place.
A slot is laid out from its own style, not from its
contents: reusing a subtree means never rendering it to measure it. Give
the slot a definite size, such as .size_full().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".