Skip to content

Commit

Permalink
Fix into_group_map_by documentation errors
Browse files Browse the repository at this point in the history
This method returns a HashMap, not an Iterator.
Bonus whitespace fix in example.

See also the `into_group_map` documentation.
  • Loading branch information
docwilco authored and phimuemue committed Dec 5, 2024
1 parent b793238 commit f80883b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3659,8 +3659,8 @@ pub trait Itertools: Iterator {
group_map::into_group_map(self)
}

/// Return an `Iterator` on a `HashMap`. Keys mapped to `Vec`s of values. The key is specified
/// in the closure.
/// Return a `HashMap` of keys mapped to `Vec`s of values. The key is specified
/// in the closure. The values are taken from the input iterator.
///
/// Essentially a shorthand for `.into_grouping_map_by(f).collect::<Vec<_>>()`.
///
Expand All @@ -3672,7 +3672,7 @@ pub trait Itertools: Iterator {
/// let lookup: HashMap<u32,Vec<(u32, u32)>> =
/// data.clone().into_iter().into_group_map_by(|a| a.0);
///
/// assert_eq!(lookup[&0], vec![(0,10),(0,20)]);
/// assert_eq!(lookup[&0], vec![(0,10), (0,20)]);
/// assert_eq!(lookup.get(&1), None);
/// assert_eq!(lookup[&2], vec![(2,12), (2,42)]);
/// assert_eq!(lookup[&3], vec![(3,13), (3,33)]);
Expand Down

0 comments on commit f80883b

Please sign in to comment.