Compile and evaluate one or more Rust expressions. If the last
expression in the Rust code returns a value (i.e., does not end with
;
), then this value is returned to R. The value returned does not need
to be of type Robj
, as long as it can be cast into this type with
.into()
. This conversion is done automatically, so you don't have to
worry about it in your code.
Usage
rust_eval(code, env = parent.frame(), ...)
Arguments
- code
Input rust code.
- env
The R environment in which the Rust code will be evaluated.
- ...
Other parameters handed off to
rust_function()
.
Examples
if (FALSE) { # \dontrun{
# Rust code without return value, called only for its side effects
rust_eval(
code = 'rprintln!("hello from Rust!");'
)
# Rust code with return value
rust_eval(
code = "
let x = 5;
let y = 7;
let z = x * y;
z // return to R; rust_eval() takes care of type conversion code
"
)
} # }