Expand description
R-side precondition generation for type checking.
Generates stopifnot() checks in R wrapper functions that run BEFORE the .Call() boundary.
This gives users clear, idiomatic R error messages with proper stack traces instead of
Rust panic messages.
Each assertion checks ONE thing with a precise error message:
add <- function(a, b) {
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,
"'b' must be numeric, logical, or raw" = is.numeric(b) || is.logical(b) || is.raw(b),
"'b' must have length 1" = length(b) == 1L
)
.Call(C_add, .call = match.call(), a, b)
}StructsΒ§
- Fallback
Param - A parameter whose Rust type is not in the static type table.
- Precondition
Output - Output of precondition analysis for a functionβs parameters.
- RAssertion π
- A single
stopifnot()assertion:"message" = condition.
EnumsΒ§
- RType
Check π - Classification of an R-side type check for a function parameter.
FunctionsΒ§
- build_
precondition_ checks - Build precondition checks for a functionβs parameters.
- extract_
single_ πgeneric_ arg - Extract the single generic type argument from a path segment.
- is_
skip_ πtype - Returns
truefor types that should never get a fallback precheck. - needs_
fallback π - Returns
trueif a type is unknown to the static type table and should be recorded as a fallback parameter. - numeric_
type_ πcheck - Build the R expression for the numeric type predicate.
- r_
check_ πfor_ reference - Map a reference type to its R-side type check.
- r_
check_ πfor_ type - Map a Rust type to its R-side type check, if applicable.
- r_
check_ πfor_ type_ path - Map a
syn::TypePathto its R-side type check. - r_
check_ πfor_ vec_ element - Map a
Vec<T>or&[T]element type to the appropriate vector type check.