Skip to main content

effective_r_defaults

Function effective_r_defaults 

Source
pub(crate) fn effective_r_defaults(
    param_defaults: &HashMap<String, String>,
    per_param: &HashMap<String, ParamAttrs>,
    c_ident: &str,
) -> HashMap<String, String>
Expand description

Effective R-formal defaults for a method.

Layers defaults in priority order:

  1. #[miniextendr(match_arg)] → ALWAYS a write-time placeholder that the cdylib resolves to c("a", "b", ...) at package-load time. Any user- supplied default = "X" is consumed elsewhere (rotates X to the front of the choice list at write time) rather than overriding the formal.
  2. #[miniextendr(choices("a", "b", ...))]c("a", "b", ...) formal default.
  3. User-provided #[miniextendr(defaults(param = "..."))] for non-match_arg params.

This formal default is load-bearing for match.arg(), not just cosmetic: base::match.arg(arg) (no explicit choices=) reads the choice list from the formal default of the calling function’s arg parameter — a match_arg/choices param with no formal default makes match.arg() fail with “argument is missing, with no default” even when the caller passed a value. Shared by MethodContext::new (inherent impls) and TraitMethodContext::new (trait impls, miniextendr_impl_trait/method_context.rs).