https://github.com/extendr/helloextendr
Minimal Example of the Rust extendr Crate
https://github.com/extendr/helloextendr
Last synced: about 1 year ago
JSON representation
Minimal Example of the Rust extendr Crate
- Host: GitHub
- URL: https://github.com/extendr/helloextendr
- Owner: extendr
- License: other
- Created: 2020-11-27T07:42:47.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-07-07T01:26:02.000Z (almost 3 years ago)
- Last Synced: 2025-04-19T04:29:03.532Z (about 1 year ago)
- Language: R
- Size: 47.9 KB
- Stars: 20
- Watchers: 6
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Minimal Example of Calling Rust from R
[](https://github.com/extendr/helloextendr/actions)
[](https://opensource.org/licenses/MIT)
This is a template package to demonstrate how to call Rust from R using the [extendr-api](https://crates.io/crates/extendr-api) crate.
## Installation
Before you can install this package, you need to install a working Rust toolchain. We recommend using [rustup.](https://rustup.rs/)
On Windows, you'll also have to add the `x86_64-pc-windows-gnu` target:
```
rustup target add x86_64-pc-windows-gnu
```
Once Rust is working, you can install this package via:
```r
remotes::install_github("extendr/helloextendr")
```
After installation, the following should work:
```r
library(helloextendr)
hello_world()
#> [1] "Hello world!"
```
## Development
### Install rextendr
You will need [rextendr](https://github.com/extendr/rextendr) package to generate wrappers.
Please install it before proceeding to the next step.
``` r
remotes::install_github("extendr/rextendr")
```
### Generate wrappers
When you make either of the following changes to the Rust source code, you'll need to regenerate the wrappers.
* add a new function
* modify the signature of an existing function
* modify the documentation written on Rust code (on the lines starting with `///`)
This can be done by:
``` r
rextendr::document()
```
Which will compile the Rust code as well as updating documentation.
## Creating your own project
For a fully worked out demonstration of how to create a Rust + R library see [here](https://extendr.github.io/rextendr/articles/package.html).