iter-group 0.3.0

Library for grouping (key,value) iterators into maps of collections
Documentation
  • Coverage
  • 100%
    13 out of 13 items documented1 out of 13 items with examples
  • Size
  • Source code size: 12.73 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.73 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • tuffy/iter-group
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • tuffy

iter-group

A trivial library to extend (key, value) iterators with a method that returns a mapping type whose keys are grouped into some collection of type value.

Essentially, it replaces this:

let a = [(1, 'a'), (2, 'b'), (3, 'c'), (2, 'd'), (1, 'e'), (1, 'f')];
let mut map: HashMap<_, Vec<_>> = HashMap::default();
for (k, v) in a.into_iter() {
    map.entry(k).or_default().push(v);
}

with this:

use iter_group:::IntoGroup;
let a = [(1, 'a'), (2, 'b'), (3, 'c'), (2, 'd'), (1, 'e'), (1, 'f')];
let map = a.into_iter().group::<HashMap<_, Vec<_>>>();

See the documentation for additional examples.