pub fn match_arg_from_sexp<T: MatchArg>(sexp: SEXP) -> Result<T, MatchArgError>Expand description
Match one choice argument with the semantics of the generated wrapper’s
match_arg check (.miniextendr_match_arg), which are those of
base::match.arg(arg, choices):
NULLis the first choice;- a factor is read as its labels;
- any other value that is not a character vector is
MatchArgError::InvalidType; - the full choices vector,
T::CHOICESin order and without attributes (what an omitted argument evaluates to when the choices are its formal default), is the first choice; - otherwise the value must have length 1 (
MatchArgError::InvalidLength) and match a choice exactly, an alias exactly (MatchArg::ALIASES), or a choice as a unique prefix (MatchArgError::NoMatch). The empty string matches nothing, andNAis matched as the string"NA", aspmatch()does (MatchArgError::IsNawhen that matches nothing).
Used by the generated TryFromSexp for T implementation, and by the
generated C wrapper of a #[miniextendr(match_arg)] parameter, which only
sees the single choice the R wrapper already matched. A body matching a raw
SEXP argument wants match_arg_param, which words its errors as the
wrapper does.