Expand description
Coerced scalar conversions (multi-source numeric) and large integer scalars.
The SEXPTYPE literals here are the source of truth (#882). They are
runtime match arms on sexp.type_of(), deliberately accepting several
source types and coercing into one target Rust type — there is no single T
whose T::SEXP_TYPE they could be folded into (the whole point is the 1:N
input fan-in). Leave them.
These types accept multiple R source types (INTSXP, REALSXP, RAWSXP, LGLSXP)
and coerce to the target Rust type via TryCoerce.
Covers: i8, i16, u16, u32, f32 (sub-native scalars) and
i64, u64, isize, usize (large integers via f64 intermediary).
§Tradeoff
This is the looser inbound path. The strict alternative is the bare
TryFromSexp impl on the matching R native
type (i32, f64, &[i32], …) — those reject any mismatched
SEXPTYPE outright instead of coercing. Failure mode of preferring the
coerced path when you wanted strict: an R caller silently passes 1.7
(REALSXP) into a Rust i32 argument and gets a truncated 1.
Outbound counterparts for the large-integer types in this module live in
crate::into_r::large_integers (lax, default) and crate::strict
(#[miniextendr(strict)] opt-in).
Functions§
- coerce_
value 🔒 - lglsxp_
na_ 🔒error - NA-rejecting error for a logical (
LGLSXP) scalar that holdsNA. - try_
from_ 🔒sexp_ numeric_ option - try_
from_ 🔒 ⚠sexp_ numeric_ option_ unchecked - try_
from_ 🔒sexp_ numeric_ scalar - try_
from_ 🔒 ⚠sexp_ numeric_ scalar_ unchecked