Skip to main content

match_arg_option_from_sexp

Function match_arg_option_from_sexp 

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

Optional form of match_arg_from_sexp for Option<T> parameters (#1473).

NULL is None (the R formal of an Option<T> choice parameter defaults to NULL, meaning no choice was made); anything else goes through the same exact-or-partial matching as the plain type and becomes Some.

Used by the generated C wrapper for #[miniextendr(match_arg)] x: Option<T> parameters instead of TryFromSexp, because Option<T> cannot carry a TryFromSexp impl for a downstream enum (orphan rule) and a T: MatchArg blanket would collide with the newtype blanket in crate::newtype.