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.
§Paired with
This is the strict outbound path. Its lax counterpart is the bare
IntoR impls for i64/u64/isize/usize (see crate::into_r).
Failure mode of staying on the lax path when you cared about exact
representation: a counter / ID just above i32::MAX lands in R as
REALSXP, and anything above 2^53 starts colliding silently.
There is no TryFromSexpStrict trait — inbound is already
strict-by-default because crate::from_r::TryFromSexp returns
Result<T, SexpError>. The looser inbound path is
crate::coerce::Coerce / crate::coerce::TryCoerce.
For storage-directed conversions (force Vec<i64> into INTSXP and error
if any element doesn’t fit) see crate::into_r_as::IntoRAs — it’s a
third path with value-based runtime checks.
Functions§
- checked_
into_ sexp_ i64 - Convert
i64to R integer, panicking if outside i32 range. - checked_
into_ sexp_ isize - Convert
isizeto R integer, panicking if outside i32 range. - checked_
into_ sexp_ u64 - Convert
u64to R integer, panicking if > i32::MAX. - checked_
into_ sexp_ usize - Convert
usizeto R integer, panicking if > i32::MAX. - checked_
option_ i64_ into_ sexp - Convert
Option<i64>to R integer in strict mode. Panics ifSome(x)is outside i32 range.NonebecomesNA_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 ifSome(x)exceeds i32::MAX.NonebecomesNA_integer_. - checked_
option_ usize_ into_ sexp - Convert
Option<usize>to R integer in strict mode. - checked_
try_ from_ sexp_ i64 - Convert R SEXP to
i64in strict mode. - checked_
try_ from_ sexp_ isize - Convert R SEXP to
isizein 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
u64in strict mode. - checked_
try_ from_ sexp_ usize - Convert R SEXP to
usizein 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 anySome(x)value is outside i32 range.NonebecomesNA_INTEGER. - checked_
vec_ option_ isize_ into_ sexp - Convert
Vec<Option<isize>>to R integer vector in strict mode. - checked_
vec_ option_ try_ from_ sexp_ i64 - Convert R SEXP to
Vec<Option<i64>>in strict mode. - checked_
vec_ option_ try_ from_ sexp_ isize - Convert R SEXP to
Vec<Option<isize>>in strict mode. - checked_
vec_ 🔒option_ try_ from_ sexp_ numeric - Generic strict
Vec<Option<T>>conversion: only INTSXP and REALSXP allowed. - checked_
vec_ option_ try_ from_ sexp_ u64 - Convert R SEXP to
Vec<Option<u64>>in strict mode. - checked_
vec_ option_ try_ from_ sexp_ usize - Convert R SEXP to
Vec<Option<usize>>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.