Skip to contents

rust() is the whole body of a function given to new_function() whose body is in the declaring package's Rust code: a Rust function of the same name, marked #[r8::function] and listed in functions of the package's r8::exports!. The declaration in R holds the parameters, their types, defaults, and descriptions, the rules, and the return type; the Rust function computes the result. r8rust_signature() writes the Rust function's signature from the declaration.

Usage

rust()

Value

Does not return: called outside a typed function, it signals r8_declaration_error.

Examples

# In a package whose Rust code holds `fn level(x: &[f64], lo: f64, hi: f64)`:
# level <- new_function(
#   "level",
#   function(x = arg_vec(type_double()), lo = arg_double(), hi = arg_double()) rust(),
#   rules = list(rule(lo <= hi)),
#   return_type = vec(type_double())
# )
try(rust())
#> Error : rust() is the body of a function given to new_function() in a package, whose Rust code holds the function's body; called by itself, it computes nothing.