Skip to main content

build_precondition_checks

Function build_precondition_checks 

Source
pub fn build_precondition_checks(
    inputs: &Punctuated<FnArg, Comma>,
    skip_params: &HashSet<String>,
    opts: &PreconditionOptions,
) -> PreconditionOutput
Expand description

Build precondition checks for a function’s parameters.

Returns the checks for known types (render them with PreconditionOutput::guards) and the parameters with unknown custom types (fallback_params). The guards read:

if (!isTRUE(is.integer(a))) .miniextendr_arg_error("a", "must be integer")
if (!isTRUE(length(a) == 1L)) .miniextendr_arg_error("a", "must have length 1")

Skips:

  • self/&self/&mut self (receiver args)
  • Parameters in skip_params (e.g., match_arg params already validated)
  • Skip types (SEXP, Dots, ExternalPtr, etc.)
  • The type-derived checks of the parameters in opts.unchecked

A parameter’s ExplicitChecks are never skipped: its class checks (inherits, then not_inherits) come before its type checks, which take the inherits message when there is one, and its NA check after them.