Skip to main content

vecsxp_from_iter

Function vecsxp_from_iter 

Source
unsafe fn vecsxp_from_iter<I>(iter: I) -> SEXP
where I: ExactSizeIterator<Item = SEXP>,
Expand description

Build a VECSXP from an exact-size iterator of child SEXPs (checked).

Routes through ListBuilder: the list is allocated and protected by a local ProtectScope before iteration begins, then the iterator is consumed inside the protected window so each child produced lazily (typically via a .map(|c| c.into_sexp()) adaptor at the callsite) is inserted immediately via ListBuilder::set, closing the GC gap.

The element type is SEXP (not a generic IntoR) deliberately: the caller performs the conversion lazily in the iterator adaptor, which keeps the trait solver from chasing the recursive Vec<Option<Vec<T>>> impl.

ยงSafety

Must be called from the R main thread.