pub fn derive_match_arg(input: DeriveInput) -> Result<TokenStream>Expand description
Main entry point for #[derive(MatchArg)].
Generates three trait implementations:
impl MatchArg– providesCHOICES(static string slice),from_choice,to_choiceimpl TryFromSexp– converts R character scalar to enum variant viamatch_arg_from_sexpimpl IntoR– converts enum variant to R character scalar viato_choice().into_sexp()
impl IntoR for Vec<Self> is provided automatically by the blanket
impl<T: MatchArg> IntoR for Vec<T> in miniextendr-api::match_arg,
so returning Vec<EnumName> from a #[miniextendr] function works
without any extra code in the user’s crate.
Validates:
- Only enums are accepted (not structs or unions)
- Generic enums are rejected
- At least one variant is required
- Only fieldless (C-style) variants are allowed
- No duplicate choice names after renaming
Choice names default to variant identifiers, optionally transformed by
#[match_arg(rename_all = "...")] or overridden per-variant with
#[match_arg(rename = "...")].