derive_variant_arm

Function derive_variant_arm 

Source
fn derive_variant_arm(
    variant: &VariantInfo<'_>,
    derive_fields: bool,
    where_clause: &mut Option<WhereClause>,
) -> TokenStream
Expand description

Generate the match arm expression for a struct or enum variant in a derived ToTyped implementation.

  • Unit variants are reified into TypedValue::Keyword, using the variant’s identifier converted with cg::to_css_identifier.
  • Variants marked with #[css(skip)] or #[typed_value(skip)] or #[typed(todo)] return None.
  • Variants with fields delegate to derive_variant_fields_expr() when derive_fields is enabled; otherwise they return None.

Note: #[css(keyword = "...")] overrides are not handled in this derive_variant_arm path. This is fine for now because all existing cases that use such overrides (e.g. #[css(keyword = "preserve-3d")]) occur in pure keyword enums, which are covered by the all-unit ToCss path. Support will need to be added here once mixed enums with keyword overrides start implementing ToTyped.