Skip to main content

derive_r_factor

Function derive_r_factor 

Source
pub fn derive_r_factor(input: DeriveInput) -> Result<TokenStream>
Expand description

Main entry point for #[derive(RFactor)].

Dispatches to either derive_simple_factor (C-style unit variants) or derive_interaction_factor (tuple variants wrapping an inner RFactor type), based on whether #[r_factor(interaction = [...])] is present.

Generates:

  • impl MatchArg (string choices for match.arg)
  • impl RFactor (1-based level index conversion)
  • impl IntoR (Rust enum -> R factor SEXP)
  • impl TryFromSexp (R factor SEXP -> Rust enum)

Returns Err for structs, unions, or invalid attribute combinations.