pub struct IntoKeys<K, V, A = Global>where
A: Allocator,{ /* private fields */ }Expand description
An owning iterator over the keys of a HashMap in arbitrary order.
The iterator element type is K.
This struct is created by the into_keys method on HashMap.
See its documentation for more.
The map cannot be used after calling that method.
ยงExamples
use rune::alloc::HashMap;
let map: HashMap<_, _> = [(1, "a"), (2, "b"), (3, "c")].try_into()?;
let mut keys = map.into_keys();
let mut vec = vec![keys.next(), keys.next(), keys.next()];
// The `IntoKeys` iterator produces keys in arbitrary order, so the
// keys must be sorted to test them against a sorted array.
vec.sort_unstable();
assert_eq!(vec, [Some(1), Some(2), Some(3)]);
// It is fused iterator
assert_eq!(keys.next(), None);
assert_eq!(keys.next(), None);