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 wrapper writer resolves to c("a", "b", ...). 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.

The Option<T> form of a choice parameter gets NULL instead (#1473), and a no_default(p) one no default at all (#1828; see ParamAttrs::choice_formal). A choice formal is documentation: the prelude (build_match_arg_prelude) passes the choice list to the helpers, which never read it off the formal (#1552). Shared by MethodContext::new (inherent impls) and TraitMethodContext::new (trait impls, miniextendr_impl_trait/method_context.rs).

param_defaults is keyed by Rust name, as defaults(p = "...") names the parameter; the result is keyed by R formal (#1842), as RArgumentBuilder::with_defaults reads it.