Skip to main content

arg_check_condition_value

Function arg_check_condition_value 

Source
pub unsafe fn arg_check_condition_value(
    message: &str,
    param: &str,
    crate_class: &[&str],
    call: Option<SEXP>,
) -> SEXP
Expand description

Build the tagged value for an argument check that failed in Rust after the conversion: #[miniextendr(no_na)] on a value its type reads as missing where R’s anyNA() saw none (the text "NA" or a blank string for AsNumeric*, a factor NA level for AsCharacter*, …), or on an Either, which has no R guard, an NA the arm taken refuses.

The condition is the one no_na’s R guard raises (.miniextendr_arg_error): kind = "conversion", message as given, the crate’s conversion_error_class (crate_class) before rust_error, and e$param. See crate::condition::arg_check_parts.

This is the generated code’s form of the argument error: it returns the value from the conversion arm and takes the classes the macro read from [package.metadata.miniextendr] at expansion time. A function body raises the same condition with the safe crate::arg_error! instead, whose classes the generated R wrapper fills in (#1740).

§Safety

Same contract as make_rust_condition_value_with_data: R main thread, valid allocation context. The generated check runs right after the argument’s conversion, where the conversion Err arms run, which satisfies it.