collect_stable_map

Function collect_stable_map 

Source
pub fn collect_stable_map<K, V, M>(iter: Iter<'_, K, V, M>) -> HashMap<K, V>
where K: Storable + Clone + Eq + Ord + Hash, V: Storable + Clone, M: Memory,
Expand description

Collects entries from a stable BTreeMap iterator into a HashMap<K, V>.

This helper is useful when converting from a stable structure (like BTreeMap<K, V, M>) to an in-memory HashMap.

§Type Parameters

  • K: The key type, which must be Storable, Clone, Ord, Eq, and Hash.
  • V: The value type, which must be Storable and Clone.
  • M: The memory backend, which must implement the Memory trait.

§Arguments

  • iter: An iterator over the entries of a stable BTreeMap.

§Returns

A HashMap<K, V> containing the collected entries.

§Example (using iter)

let map = collect_stable_map(my_stable_map.iter());

§Example (using range)

let range = my_stable_map.range(2..3);
let entries = collect_stable_map(range);