]>
git.proxmox.com Git - rustc.git/blob - vendor/itertools-0.7.8/src/group_map.rs
1 #![cfg(feature = "use_std")]
3 use std
::collections
::HashMap
;
5 use std
::iter
::Iterator
;
7 /// Return a `HashMap` of keys mapped to a list of their corresponding values.
9 /// See [`.into_group_map()`](../trait.Itertools.html#method.into_group_map)
10 /// for more information.
11 pub fn into_group_map
<I
, K
, V
>(iter
: I
) -> HashMap
<K
, Vec
<V
>>
12 where I
: Iterator
<Item
=(K
, V
)>,
15 let mut lookup
= HashMap
::new();
17 for (key
, val
) in iter
{
18 lookup
.entry(key
).or_insert(Vec
::new()).push(val
);