Method in collections::map · HashMap coil-stdlib

HashMap::iter

pub fn iter() -> HashMapIter<K, V>
Import
use collections::map::{HashMap};
Source: 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#

↑ ↓ navigate ↵ open