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>,
) -> PreconditionOutput
Expand description

Build precondition checks for a function’s parameters.

Returns:

  • static_checks: Lines forming a stopifnot(...) call for known types
  • fallback_params: Parameters needing validation (unknown custom types)

Static checks produce R-side stopifnot():

stopifnot(
  "'a' must be numeric, logical, or raw" = is.numeric(a) || is.logical(a) || is.raw(a),
  "'a' must have length 1" = length(a) == 1L
)

Skips:

  • self/&self/&mut self (receiver args)
  • Parameters in skip_params (e.g., match_arg params already validated)
  • Skip types (SEXP, Dots, ExternalPtr, etc.)