Skip to main content

match_arg_missing_or

Function match_arg_missing_or 

Source
pub fn match_arg_missing_or<U, E>(
    sexp: SEXP,
    inner: impl FnOnce(SEXP) -> Result<U, E>,
) -> Result<Missing<U>, E>
Expand description

The Missing<_> layer of a choice parameter (#1551): the missing-argument sentinel is Missing::Absent, anything else (NULL included) is decoded by inner and becomes Missing::Present.

The generated R wrapper keeps the choice vector as the formal default, skips the match.arg() check for an omitted argument and forwards R’s missing-argument sentinel (if (missing(x)) quote(expr=) else x), so #[miniextendr(match_arg)] mode: Missing<Option<Mode>> reaches Rust as Absent when omitted, Present(None) for NULL, and Present(Some(mode)) for a matched choice. A single-choice parameter treats its formal passed whole the same way (#2152): for a value identical() to the choice vector the wrapper skips the check and forwards the sentinel (if (missing(x) || identical(x, c(...))) quote(expr=) else x), so it is Absent too; a several_ok list reads that vector as every choice. The C wrapper decodes it with match_arg_missing_or(sexp, match_arg_option_from_sexp::<Mode>).