Skip to main content

match_arg_formal

Function match_arg_formal 

Source
#[doc(hidden)]
pub fn match_arg_formal( choices: &[&str], preferred: &str, placeholder: &str, ) -> String
Expand description

The R formal of a match_arg parameter, c("a", "b"), that the wrappers writer splices in place of its placeholder: choices (the type’s MatchArg::CHOICES), each quoted and escaped for an R string literal (escape_r_string).

With a default = "..." (preferred: the literal’s text without its quotes, so escaped as R source is), that choice comes first and the others keep their order (crate::match_arg::default_first, the order crate::match_arg::match_arg_param_with_default matches against, #1767). An empty preferred keeps the declaration order.

A preferred that names no choice panics with the placeholder: the wrappers writer is the only caller, so the panic surfaces as a load-time error in the host R session rather than a broken wrapper.