rust_fn {cargo}R Documentation

Define an R Function Implemented in Rust

Description

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.

Usage

rust_fn(
  ...,
  dependencies = character(0),
  minimum_version = "1.31.0",
  verbose = FALSE,
  cached = TRUE,
  longjmp = TRUE,
  invisible = FALSE,
  force = FALSE
)

Arguments

...

Rust code is taken as a string from the last unnamed argument, and variable names come for all other unnamed arguments. See example.

dependencies

A character vector of crate dependencies, e.g., c('rand = "0.8.5"','rand_pcg = "0.3.1"').

minimum_version

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.

verbose

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.

cached

Should Cargo use previously compiled artifacts?

longjmp

Should the compiled function use the faster (but experimental) longjmp functionality when Rust code panics?

invisible

Should the compiled function return values invisibly?

force

If TRUE, write to cache directory on first usage without asking for user confirmation.

Value

An R function implemented with the supplied Rust code.


[Package cargo version 0.4.9 Index]