Expand description
Conversions from Rust types to R SEXP.
This module provides the IntoR trait for converting Rust values to R SEXPs.
§Submodules
| Module | Contents |
|---|---|
large_integers | i64, u64, isize, usize → REALSXP, plus string/bool/Option scalars |
collections | HashMap, BTreeMap, HashSet, BTreeSet → named/unnamed lists |
result | Result<T, E> → list with ok/err fields |
altrep | Altrep<T> marker type, Lazy<T> alias, IntoRAltrep trait |
§Thread Safety
The trait provides two methods:
IntoR::into_sexp- checked version with debug thread assertionsIntoR::into_sexp_unchecked- unchecked version for performance-critical paths
Use into_sexp_unchecked when you’re certain you’re on the main thread:
- Inside ALTREP callbacks
- Inside
#[miniextendr(unsafe(main_thread))]functions - Inside
extern "C-unwind"functions called directly by R
Modules§
- altrep 🔒
- ALTREP marker type (
Altrep<T>/Lazy<T>). - collections 🔒
- Collection conversions (HashMap, BTreeMap, HashSet, BTreeSet) to R.
- large_
integers 🔒 - Large integer types → REALSXP (f64).
- result 🔒
Result<T, E>conversions to R.
Macros§
- impl_
into_ 🔒r_ via_ coerce - Macro for infallible widening IntoR via Coerce.
- impl_
lossy_ 🔒string_ into_ r - Generate IntoR impls for types with
to_string_lossy()(owned scalar, ref scalar, Option, Vec, Vec - impl_
option_ 🔒collection_ into_ r - impl_
scalar_ 🔒into_ r - Macro for scalar IntoR via Rf_Scalar* functions.
- impl_
set_ 🔒coerce_ into_ r - Macro for
HashSet<T>/BTreeSet<T>whereTcoerces to i32 (R’s native integer type). - impl_
tuple_ 🔒into_ r - Macro to implement IntoR for tuples of various sizes. Converts Rust tuples to unnamed R lists (VECSXP).
- impl_
vec_ 🔒coerce_ into_ r - Macro for
Vec<T>whereTcoerces to a native R type. - impl_
vec_ 🔒map_ into_ r - impl_
vec_ 🔒option_ coerce_ into_ r - Macro for
Vec<Option<T>>whereTcoerces to a type with existing Option impl. - impl_
vec_ 🔒option_ into_ r - Macro for NA-aware
Vec<Option<T>> → Rvector conversions. - impl_
vec_ 🔒option_ logical_ into_ r - impl_
vec_ 🔒option_ smart_ i64_ into_ r - Macro for NA-aware
Vec<Option<T>> → Rsmart vector conversion. Checks if all non-None values fit i32 → INTSXP, otherwise REALSXP. - impl_
vec_ 🔒smart_ i64_ into_ r
Structs§
Traits§
- IntoR
- Trait for converting Rust types to R SEXP values.
- IntoR
Altrep - Extension trait for ALTREP conversions.
Functions§
- alloc_
r_ 🔒 ⚠vector - Allocate an R vector of type
Twithnelements and return(SEXP, &mut [T]). - alloc_
r_ 🔒 ⚠vector_ unchecked - Allocate an R vector (unchecked FFI variant).
- logical_
iter_ 🔒to_ lglsxp - Helper: allocate LGLSXP and fill from an i32 iterator (checked).
- logical_
iter_ 🔒 ⚠to_ lglsxp_ unchecked - Helper: allocate LGLSXP and fill from an i32 iterator (unchecked).
- str_
iter_ 🔒to_ strsxp - Helper: allocate STRSXP and fill from a string iterator (checked).
- str_
iter_ 🔒 ⚠to_ strsxp_ unchecked - Helper: allocate STRSXP and fill from a string iterator (unchecked).
- try_
recover_ 🔒cow_ slice - Try SEXP pointer recovery for a borrowed Cow slice.
- vec_
of_ 🔒into_ r_ to_ list - Helper: convert a Vec of IntoR items to an R list (VECSXP).
- vec_
of_ 🔒maps_ to_ list - Helper to convert a Vec of map-like types to an R list of named lists.
- vec_
to_ 🔒 ⚠sexp - Convert a slice to an R vector (checked) using
copy_from_slice. - vec_
to_ 🔒 ⚠sexp_ unchecked - Convert a slice to an R vector (unchecked) using
copy_from_slice.
Type Aliases§
- Lazy
- Marker type to opt-in to ALTREP representation for types that have both eager-copy and ALTREP implementations.