collect_stable_vec

Function collect_stable_vec 

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

Collects entries from a stable BTreeMap iterator into a Vec<(K, V)>.

This is useful when working with ic-stable-structures’s BTreeMap and you want to extract all entries as a vector of key-value pairs.

§Type Parameters

  • K: The key type, which must be Storable, Clone, and Ord.
  • 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 vector containing (K, V) pairs.

§Example (using iter)

let vec = collect_stable_vec(my_stable_map.iter());

§Example (using range)

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