Skip to main content

match_arg_vec_from_sexp

Function match_arg_vec_from_sexp 

Source
pub fn match_arg_vec_from_sexp<T: MatchArg>(
    sexp: SEXP,
) -> Result<Vec<T>, MatchArgError>
Expand description

Extract multiple strings from an R SEXP (STRSXP) and match each against the choices of a MatchArg type.

Used by the generated C wrapper for match_arg + several_ok parameters (match.arg with several.ok = TRUE).

NULL input returns all variants. The R prelude’s strict several_ok helper maps NULL the same way and rejects any element that matches no choice before the value reaches this function, so the per-element check here is the second line of defence, not the only one (#1472). Under an Either<Vec<T>, R> parameter (#1612), match_arg_either_or calls it only for character or factor input, so NULL never reaches it there.

Note: factors (INTSXP) are not handled here — the R wrapper coerces factors to character before the .Call() boundary, on the Either path too.