Skip to main content

FieldSection

Derive Macro FieldSection 

Source
#[derive(FieldSection)]
{
    // Attributes available to this derive:
    #[field]
    #[fields]
}
Expand description

Derive the interpretation of a field section from a struct’s declarations.

Each member of the struct is declared with #[field("name")], naming a field in lowercase, or #[fields(flatten)], embedding another section. A declared member’s type says how its instances combine: Option<T> for an optional singleton, T for a required one, and Vec<T> for a list or separate field. #[field("name", invalid = "ignore")] overrides the field type’s invalid-value policy, except that a required field always treats an invalid value as an error. On the struct, #[fields(forbid("name", ...))] forbids fields, and #[fields(unknown = "reject")] rejects fields it neither declares nor forbids, which are otherwise ignored. A section may have one lifetime parameter, for values it borrows from the input.