HashMap::iter
pub fn iter() -> HashMapIter<K, V> Import
Source: use collections::map::{HashMap}; src/collections/map.hy Returns an iterator over the entries, in insertion order.
for e in m does the same; each item is an Entry with key and value.
Called on a HashMap value as value.iter(…).
Returns#
HashMapIter<K, V>
Examples#
use collections::map::{HashMap};
use tests::assert;
let m: HashMap<string, int> = HashMap::new();
m.insert("a", 1);
let it = m.iter();
let first = match it.next() {
Option::Some(e) => e.key,
Option::None => "",
};
assert!(first == "a");
See also#
collections::map::EntryHashMap: A hash map from keys of typeKto values of typeV.HashMap::with_capacity: Creates an empty map with room for aboutcapbuckets before it grows.HashMap::new: Creates an empty map.HashMap::size: Returns the number of entries.HashMap::is_empty: Returnstruewhen the map has no entries.HashMap::capacity: Returns the number of buckets.HashMap::clear: Removes every entry, keeping the bucket count.