Expand description
Named atomic vector wrapper for HashMap/BTreeMap ↔ named R atomic vector conversions.
By default, HashMap<String, V> and BTreeMap<String, V> convert to/from named R
lists (VECSXP). This module provides NamedVector for converting to/from named
atomic vectors (INTSXP, REALSXP, LGLSXP, RAWSXP, STRSXP) instead — a more
compact and idiomatic representation when values are scalar.
§Example
ⓘ
use std::collections::HashMap;
use miniextendr_api::NamedVector;
#[miniextendr]
fn make_scores() -> NamedVector<HashMap<String, i32>> {
let mut m = HashMap::new();
m.insert("alice".into(), 95);
m.insert("bob".into(), 87);
NamedVector(m)
}
// In R: make_scores() returns c(alice = 95L, bob = 87L)Structs§
- Named
Vector - Wrapper that converts a map to/from a named atomic R vector instead of a named list.
Traits§
- Atomic
Element - Marker trait for types that can be elements of named atomic R vectors.
Functions§
- extract_
names_ 🔒strict - Extract names from an R SEXP with strict validation.
- set_
names_ 🔒 ⚠on_ sexp - Set names attribute on an R SEXP from a slice of name-like values.