Derive Macro silkenweb::Element

source ·
#[derive(Element)]
{
    // Attributes available to this derive:
    #[element]
}
Expand description

Derive Element.

This only works for structs. It will defer to one field for the implementation. If multiple fields are present, a target field must be specified with #[element(target)].

§Example

Derive traits for a newtype struct:

#[derive(Element)]
struct MyElement<D: Dom>(Div<D>);

When the struct has more than 1 field:

#[derive(Element)]
struct MyElement<D: Dom, Data> {
    #[element(target)]
    element: Div<D>,
    data: Data,
}