| rust_eval | R Documentation |
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.
rust_eval(code, env = parent.frame(), ...)
code |
Input rust code. |
env |
The R environment in which the Rust code will be evaluated. |
... |
Other parameters handed off to |
The return value generated by the Rust code.
## Not run:
# 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
"
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.