This function takes Rust code as a string from the last unnamed argument, takes variable names for all other unnamed arguments, compiles the Rust function, and wraps it as an R function.
rust_fn(
...,
dependencies = character(0),
minimum_version = "1.31.0",
verbose = FALSE,
cached = TRUE,
longjmp = TRUE,
invisible = FALSE,
force = FALSE
)
An R function implemented with the supplied Rust code.
Rust code is taken as a string from the last unnamed argument, and variable names come for all other unnamed arguments. See example.
A character vector of crate dependencies, e.g.,
c('rand = "0.8.5"','rand_pcg = "0.3.1"')
.
A character string representing the minimum version of
Rust that is needed. Or a path to the root of a package (i.e., the
directory containing the DESCRIPTION file), in which case the value is
found from the field: SystemRequirements: Cargo (>= XXXX)
. For the
search_methods
being "cache"
, the shell command rustup
is used to upgrade the Cargo installation if needed.
If TRUE
, Cargo prints compilation details. If
FALSE
, Cargo is run in quiet mode, except for the first time this
function is run. If "never"
, Cargo is always run in quiet mode. In
any case, errors in code are always shown.
Should Cargo use previously compiled artifacts?
Should the compiled function use the faster (but experimental) longjmp functionality when Rust code panics?
Should the compiled function return values invisibly?
If TRUE
, write to cache directory on first usage without
asking for user confirmation.