Skip to main content

MatchArg

Derive Macro MatchArg 

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

Derive MatchArg: enables conversion between Rust enums and R character strings with match.arg semantics (partial matching, informative errors).

§Usage

#[derive(Copy, Clone, MatchArg)]
enum Mode {
    Fast,
    Safe,
    Debug,
}

§Attributes

  • #[match_arg(rename = "name")] - Rename a variant’s choice string
  • #[match_arg(rename_all = "snake_case")] - Rename all variants (snake_case, kebab-case, lower, upper)

§Generated Implementations

  • MatchArg - Choice metadata and bidirectional conversion
  • TryFromSexp - Convert R STRSXP/factor to enum (with partial matching)
  • IntoR - Convert enum to R character scalar