Function hash_map

Source
pub fn hash_map<P, K, V>(parser: P) -> MapParser<P, Collect<HashMap<K, V>>>
where P: Parser, P::Output: IntoIterator<Item = (K, V)>,
Expand description

Convert the output of parser from a Vec<(K, V)> or other collection of pairs into a HashMap.

For example, the parser lines(alpha " = " u64) produces a Vec<(char, u64)>. Wrapping that parser in hash_map makes it produce a HashMap<char, u64> instead:

let p = parser!(hash_map(lines(alpha " = " u64)));

let h = p.parse("X = 33\nY = 75\n").unwrap();
assert_eq!(h[&'X'], 33);
assert_eq!(h[&'Y'], 75);