pub trait AddTo<Collector: ?Sized> {
type Handle<'a>
where Collector: 'a;
// Required method
fn add_to(self, collector: &mut Collector) -> Self::Handle<'_>;
}Expand description
Trait for adding a value to a child collector.
The element! macro dispatches all child additions through this trait,
enabling compile-time type checking of parent-child relationships.
If you try to nest a component inside a parent that doesn’t accept it,
you’ll get a compile error rather than a runtime panic.
§Implementations
Required Associated Types§
Required Methods§
Sourcefn add_to(self, collector: &mut Collector) -> Self::Handle<'_>
fn add_to(self, collector: &mut Collector) -> Self::Handle<'_>
Add this value to the collector, returning a handle for chaining
.key() and .width().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl AddTo<Elements> for String
String → Elements: creates a Text component with the string as content.
impl AddTo<Elements> for String
String → Elements: creates a Text component with the string as content.
This powers the element! string literal sugar — "hello" becomes a
Text component. The same AddTo dispatch also works
inside data children contexts (e.g., Text { "hello" }) via the
Into<TextChild> blanket impl.
type Handle<'a> = ElementHandle<'a>
fn add_to(self, els: &mut Elements) -> ElementHandle<'_>
Implementors§
Source§impl<C: Component> AddTo<Elements> for ComponentWithSlot<C>
impl<C: Component> AddTo<Elements> for ComponentWithSlot<C>
type Handle<'a> = ElementHandle<'a>
Source§impl<C: Component> AddTo<Elements> for C
Blanket: any Component can be added to Elements.
impl<C: Component> AddTo<Elements> for C
Blanket: any Component can be added to Elements.
type Handle<'a> = ElementHandle<'a>
Source§impl<T, V: Into<T>> AddTo<DataChildren<T>> for V
Any type that converts Into<T> can be added to a DataChildren<T> collector.
impl<T, V: Into<T>> AddTo<DataChildren<T>> for V
Any type that converts Into<T> can be added to a DataChildren<T> collector.