Skip to main content

from_numeric_vec_with

Function from_numeric_vec_with 

Source
pub(crate) fn from_numeric_vec_with<U, FI, FD, FR, FL>(
    sexp: SEXP,
    map_i32: FI,
    map_f64: FD,
    map_u8: FR,
    map_lgl: FL,
) -> Result<Vec<U>, SexpError>
where FI: Fn(i32) -> Result<U, SexpError>, FD: Fn(f64) -> Result<U, SexpError>, FR: Fn(u8) -> Result<U, SexpError>, FL: Fn(RLogical) -> Result<U, SexpError>,
Expand description

Shared SEXP-dispatch shell for coerced numeric/logical/raw vectors.

Reads INTSXP/REALSXP/RAWSXP/LGLSXP and applies the per-element map. The only behavioural axis (NA policy) lives entirely in the four closures the caller passes, so the NA-unaware try_from_sexp_numeric_vec and the NA-aware try_from_sexp_numeric_option_vec (in na_vectors) share one dispatch. LGLSXP NA (NA_LOGICAL) and INTSXP NA (i32::MIN) round through as raw sentinels here; any NA-to-None policy is the caller’s closure to encode.