Skip to content

Commit 5d1d4aa

Browse files
bors[bot]jplatte
andauthored
Merge #536
536: Improve docs for into_group_map_by r=phimuemue a=jplatte * Fix a typo * Fix formatting of example * Use more inline code markup Co-authored-by: Jonas Platte <[email protected]>
2 parents 59cb6f5 + 609c089 commit 5d1d4aa

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/lib.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2724,18 +2724,18 @@ pub trait Itertools : Iterator {
27242724
group_map::into_group_map(self)
27252725
}
27262726

2727-
/// Return an `Iterator` on a HahMap. Keys mapped to `Vec`s of values. The key is specified in
2727+
/// Return an `Iterator` on a `HashMap`. Keys mapped to `Vec`s of values. The key is specified
27282728
/// in the closure.
2729-
/// Different of into_group_map_by because the key is still present. It is also more general.
2730-
/// you can also fold the group_map.
2729+
/// Different to `into_group_map_by` because the key is still present. It is also more general.
2730+
/// You can also fold the `group_map`.
27312731
///
27322732
/// ```
27332733
/// use itertools::Itertools;
27342734
/// use std::collections::HashMap;
27352735
///
27362736
/// let data = vec![(0, 10), (2, 12), (3, 13), (0, 20), (3, 33), (2, 42)];
2737-
/// let lookup: HashMap<u32,Vec<(u32, u32)>> = data.clone().into_iter().into_group_map_by(|a|
2738-
/// a.0);
2737+
/// let lookup: HashMap<u32,Vec<(u32, u32)>> =
2738+
/// data.clone().into_iter().into_group_map_by(|a| a.0);
27392739
///
27402740
/// assert_eq!(lookup[&0], vec![(0,10),(0,20)]);
27412741
/// assert_eq!(lookup.get(&1), None);
@@ -2744,10 +2744,12 @@ pub trait Itertools : Iterator {
27442744
///
27452745
/// assert_eq!(
27462746
/// data.into_iter()
2747-
/// .into_group_map_by(|x| x.0)
2748-
/// .into_iter()
2749-
/// .map(|(key, values)| (key, values.into_iter().fold(0,|acc, (_,v)| acc + v )))
2750-
/// .collect::<HashMap<u32,u32>>()[&0], 30)
2747+
/// .into_group_map_by(|x| x.0)
2748+
/// .into_iter()
2749+
/// .map(|(key, values)| (key, values.into_iter().fold(0,|acc, (_,v)| acc + v )))
2750+
/// .collect::<HashMap<u32,u32>>()[&0],
2751+
/// 30,
2752+
/// );
27512753
/// ```
27522754
#[cfg(feature = "use_std")]
27532755
fn into_group_map_by<K, V, F>(self, f: F) -> HashMap<K, Vec<V>>

0 commit comments

Comments
 (0)