Skip to main content

Module collections

Module collections 

Source
Expand description

Collection conversions (HashMap, BTreeMap, HashSet, BTreeSet) to R.

  • HashMap<String, V> / BTreeMap<String, V> → named R list
  • HashSet<T> / BTreeSet<T> → unnamed R vector (via Vec intermediary)

§Tradeoff

Choose BTreeMap over HashMap when stable element order in the resulting R list matters (testthat snapshots, deterministic file output) — HashMap iteration order is unspecified and varies between runs. The same applies to BTreeSet vs HashSet. Failure mode of using HashMap for a result the user expect_equal()s by position: flaky tests across runs / R versions.

Inbound counterpart: crate::from_r::collections.

Macros§

impl_map_into_r 🔒
impl_set_string_into_r 🔒

Functions§

map_to_named_list 🔒
Helper to convert an iterator of (String, V) pairs to a named R list.
map_to_named_list_unchecked 🔒
Unchecked version of map_to_named_list.