Skip to main content

map_strsxp_with

Function map_strsxp_with 

Source
pub(crate) fn map_strsxp_with<U>(
    sexp: SEXP,
    map: impl FnMut(SEXP, usize) -> Result<U, SexpError>,
) -> Result<Vec<U>, SexpError>
Expand description

Shared SEXP-dispatch shell for the STRSXP (character vector) walk.

String-side counterpart of from_numeric_vec_with: checks STRSXP, walks each element via string_elt, and applies the per-element map closure to the raw CHARSXP. NA/blank-string policy ("" vs None vs error) and the target representation (String vs &str vs Cow) are entirely the caller’s closure to encode — this only centralizes the type check and the walk.

Mirrors from_numeric_vec_with’s choice to route both the checked and unchecked TryFromSexp paths through the same (checked-FFI) walk — none of the current STRSXP vector impls define a distinct unchecked fast path (they fall back to TryFromSexp’s default try_from_sexp_unchecked, which just calls the checked version), so there is no unchecked-FFI twin here.