Skip to main content

Module strict

Module strict 

Source
Expand description

Strict conversion helpers for #[miniextendr(strict)].

These functions panic instead of silently widening when a value cannot be exactly represented as an R integer (INTSXP). This provides an opt-in alternative to the default IntoR behavior which silently falls back to REALSXP (f64) for out-of-range values.

§Motivation

R has no native 64-bit integer type. The default i64::into_sexp() picks INTSXP when the value fits and REALSXP otherwise — silently losing precision for values outside [-2^53, 2^53]. With #[miniextendr(strict)], the macro generates calls to these helpers instead, which panic (→ R error) if the value doesn’t fit in i32.

Functions§

checked_into_sexp_i64
Convert i64 to R integer, panicking if outside i32 range.
checked_into_sexp_isize
Convert isize to R integer, panicking if outside i32 range.
checked_into_sexp_u64
Convert u64 to R integer, panicking if > i32::MAX.
checked_into_sexp_usize
Convert usize to R integer, panicking if > i32::MAX.
checked_option_i64_into_sexp
Convert Option<i64> to R integer in strict mode. Panics if Some(x) is outside i32 range. None becomes NA_integer_.
checked_option_isize_into_sexp
Convert Option<isize> to R integer in strict mode.
checked_option_u64_into_sexp
Convert Option<u64> to R integer in strict mode. Panics if Some(x) exceeds i32::MAX. None becomes NA_integer_.
checked_option_usize_into_sexp
Convert Option<usize> to R integer in strict mode.
checked_try_from_sexp_i64
Convert R SEXP to i64 in strict mode.
checked_try_from_sexp_isize
Convert R SEXP to isize in strict mode.
checked_try_from_sexp_numeric_scalar 🔒
Generic strict scalar conversion: only INTSXP and REALSXP allowed.
checked_try_from_sexp_u64
Convert R SEXP to u64 in strict mode.
checked_try_from_sexp_usize
Convert R SEXP to usize in strict mode.
checked_vec_i64_into_sexp
Convert Vec<i64> to R integer vector, panicking if any element is outside i32 range.
checked_vec_isize_into_sexp
Convert Vec<isize> to R integer vector, panicking if any element is outside i32 range.
checked_vec_option_i64_into_sexp
Convert Vec<Option<i64>> to R integer vector in strict mode. Panics if any Some(x) value is outside i32 range. None becomes NA_INTEGER.
checked_vec_option_isize_into_sexp
Convert Vec<Option<isize>> to R integer vector in strict mode.
checked_vec_option_u64_into_sexp
Convert Vec<Option<u64>> to R integer vector in strict mode.
checked_vec_option_usize_into_sexp
Convert Vec<Option<usize>> to R integer vector in strict mode.
checked_vec_try_from_sexp_i64
Convert R SEXP to Vec<i64> in strict mode.
checked_vec_try_from_sexp_isize
Convert R SEXP to Vec<isize> in strict mode.
checked_vec_try_from_sexp_numeric 🔒
Generic strict vector conversion: only INTSXP and REALSXP allowed.
checked_vec_try_from_sexp_u64
Convert R SEXP to Vec<u64> in strict mode.
checked_vec_try_from_sexp_usize
Convert R SEXP to Vec<usize> in strict mode.
checked_vec_u64_into_sexp
Convert Vec<u64> to R integer vector, panicking if any element > i32::MAX.
checked_vec_usize_into_sexp
Convert Vec<usize> to R integer vector, panicking if any element > i32::MAX.