Expand description
NA-aware vector conversions (Vec<Option<T>>, Box<[Option<T>]>).
The SEXPTYPE literals here are the source of truth (#882). The macro
that generates the native-type impls is passed the tag as $sexptype from the
caller (where the concrete element type is known); the hand-written logical
impls use LGLSXP because bool/Rboolean are not RNativeType (R logicals
are i32), and the string/raw impls use STRSXP/RAWSXP literals because
those element types have no RNativeType collapse — leave them.
Maps R’s NA values to None and non-NA values to Some(v).
Covers native types (i32, f64, u8), logical (bool, Rboolean, RLogical),
string (Option<String>), complex (Option<Rcomplex>), and coerced
numeric types (Option<i64>, Option<u64>, etc.).
§Tradeoff
Use the NA-unaware sibling impls (Vec<T>, Box<[T]>) when R guarantees
no NA — they’re cheaper (no per-element Option discriminant) and reject
NA at conversion time. Failure mode of binding plain Vec<i32> when the
R caller can pass NA_integer_: a single NA element silently round-trips
as i32::MIN, the R NA sentinel, which is a footgun for arithmetic
downstream.
Outbound counterpart: Vec<Option<T>> impls in crate::into_r.
Macros§
- impl_
vec_ 🔒option_ try_ from_ sexp - Macro for NA-aware
R vector → Vec<Option<T>>conversions. - impl_
vec_ 🔒option_ try_ from_ sexp_ numeric