User Guide
A comprehensive guide to using extendr
This user guide focuses on developing R packages that call Rust code and publishing them to CRAN. A basic understanding of Rust is assumed. If you are new to Rust, start with the Rust Basics section.
Core Concepts
- The
#[extendr]macro: How to expose Rust functions and structs to R. - R to Rust type mapping: An overview of how R types map to extendr types.
- Conversion to and from R data: Converting between R and Rust values using
From,Into, andTryFrom.
Type Mapping
- Scalar Type Mapping: Working with R scalar values in Rust.
- Vector Type Mapping: Working with R vectors in Rust.
- Using HashMaps: Working with R named lists and Rust
HashMaps. - Rust Structs to Lists: Exposing Rust structs as R lists.
- Default function arguments: Handling optional and default arguments.
Integrations
serdeintegration: Serializing and deserializing Rust types withserde.- Async with Tokio: Using async Rust with Tokio inside extendr.
- Building for WebR: Compiling extendr packages for WebR.
Publishing
- Publishing to CRAN: Steps and considerations for submitting an extendr package to CRAN.
- CRAN’s Rust versions: Understanding CRAN’s minimum supported Rust version policy.
FAQ
What’s not in this guide?
This guide is not a comprehensive introduction to Rust. Concepts are introduced only to explain extendr tools. To learn more about Rust, consult “The Book”.
This guide is also not a comprehensive guide to R package development. Better resources exist for that, notably R Packages (2e). We will point you to relevant external resources as needed.
Software requirements
This guide assumes the following versions of necessary software:
- R: 4.2
- Rust 1.65.0
- extendr-api 0.8.1
- rextendr 0.4.2.9000
Please see Get Started if you have not already installed this software.