Skip to main content

BasecoatProps

Derive Macro BasecoatProps 

Source
#[derive(BasecoatProps)]
{
    // Attributes available to this derive:
    #[prop]
}
Expand description

#[derive(BasecoatProps)] generates a builder for component prop structs.

§Field attributes

  • #[prop(default)] — field uses Default::default() if not provided in builder.
  • #[prop(default = expr)] — field uses expr if not provided.
  • #[prop(into)] — builder setter accepts impl Into<FieldType>.
  • #[prop(optional)] — field is Option<T>; missing → None.
  • #[prop(extend)] — marks the AttrMap catch-all field (at most one per struct).

§Builder design choice

We use a runtime-panic builder for v0.1. A typestate builder would require one phantom-type parameter per required field and substantially more generated code. For a UI component library where every field is either optional or has a default, the extra complexity of typestate adds no practical safety benefit. If a required field (no default/optional) is omitted, build() panics with a clear message.

§Hydration helper

A const __BASECOAT_EXTEND_FIELD: Option<&'static str> associated constant is emitted on the props struct so the rsx! macro (phase 2c) can discover at compile time where to push unknown HTML attributes.