Skip to main content

Module into_r

Module into_r 

Source
Expand description

Conversions from Rust types to R SEXP.

This module provides the IntoR trait for converting Rust values to R SEXPs.

§Submodules

ModuleContents
large_integersi64, u64, isize, usize → REALSXP, plus string/bool/Option scalars
collectionsHashMap, BTreeMap, HashSet, BTreeSet → named/unnamed lists
resultResult<T, E> → list with ok/err fields
altrepAltrep<T> marker type, Lazy<T> alias, IntoRAltrep trait

§Thread Safety

The trait provides two methods:

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> where T coerces 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> where T coerces to a native R type.
impl_vec_map_into_r 🔒
impl_vec_option_coerce_into_r 🔒
Macro for Vec<Option<T>> where T coerces to a type with existing Option impl.
impl_vec_option_into_r 🔒
Macro for NA-aware Vec<Option<T>> → R vector conversions.
impl_vec_option_logical_into_r 🔒
impl_vec_option_smart_i64_into_r 🔒
Macro for NA-aware Vec<Option<T>> → R smart vector conversion. Checks if all non-None values fit i32 → INTSXP, otherwise REALSXP.
impl_vec_smart_i64_into_r 🔒

Structs§

Altrep
NullOnErr
Marker type for Result<T, ()> that converts Err(()) to NULL.

Traits§

IntoR
Trait for converting Rust types to R SEXP values.
IntoRAltrep
Extension trait for ALTREP conversions.

Functions§

alloc_r_vector 🔒
Allocate an R vector of type T with n elements 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.