From f80883b8e01cba2f8ef872cd33d6eda1a471db4c Mon Sep 17 00:00:00 2001 From: docwilco <66911096+docwilco@users.noreply.github.com> Date: Thu, 5 Dec 2024 15:00:15 +0100 Subject: [PATCH] Fix into_group_map_by documentation errors This method returns a HashMap, not an Iterator. Bonus whitespace fix in example. See also the `into_group_map` documentation. --- src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a4bb5e46c..834a48dea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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::>()`. /// @@ -3672,7 +3672,7 @@ pub trait Itertools: Iterator { /// let lookup: HashMap> = /// 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)]);