Skip to main content

Module large_integers

Module large_integers 

Source
Expand description

Large integer types → REALSXP (f64).

R doesn’t have native 64-bit integers. These types convert to f64 (REALSXP) which may lose precision for values outside the “safe integer” range.

§Tradeoff

These are the lax outbound impls — values in (i32::MIN, i32::MAX] become INTSXP and everything else silently widens to REALSXP, with precision loss above 2^53. The strict alternative is crate::strict::checked_into_sexp_i64 (and the u64/isize/usize siblings), reached via #[miniextendr(strict)] — those panic (→ R error) instead of widening. Failure mode of staying on the lax path with IDs/counters: collisions once values exceed 2^53 (≈ 9 × 10^15).

For storage-directed conversions (force INTSXP, error if out of range) see crate::into_r_as::IntoRAs.

Macros§

impl_logical_into_r 🔒
Macro for logical IntoR via Rf_ScalarLogical with conversion to i32.
impl_option_coerce_into_r 🔒
Macro for Option<T> where T coerces to a type with existing Option impl.
impl_option_smart_i64_into_r 🔒
Macro for NA-aware Option<T> → R smart scalar conversion. Checks if value fits i32 → INTSXP with NA_INTEGER for None, otherwise REALSXP with NA_REAL for None.

Functions§

str_to_charsxp 🔒
Helper to convert a string slice to R CHARSXP. Uses UTF-8 encoding. Empty strings return R_BlankString (static, no allocation).
str_to_charsxp_unchecked 🔒
Unchecked version of str_to_charsxp.
vec_externalptr_to_list 🔒
Allocate a VECSXP and populate it with the external pointers in items.
vec_option_externalptr_to_list 🔒
As vec_externalptr_to_list, but None elements become NULL.