Derive Macro silkenweb::ChildElement
source · #[derive(ChildElement)]
{
// Attributes available to this derive:
#[child_element]
}
Expand description
Derive the traits needed for a blanket implmenetation of ChildElement
.
This only works for structs. It will defer to one field for the
implementation of the traits. If multiple fields are present, a target field
must be specified with #[child_element(target)]
.
Example
Derive traits for a newtype struct:
#[derive(ChildElement)]
struct MyComponent<D: InstantiableDom>(Component<D>);
Derive traits when the struct has more than 1 field:
#[derive(ChildElement)]
struct MyComponent<D: InstantiableDom, Data> {
#[child_element(target)]
component: Component<D>,
data: Data,
}