6 releases (3 breaking)
0.4.0 | Aug 29, 2021 |
---|---|
0.3.0 | Jun 17, 2021 |
0.2.0 | Jun 14, 2021 |
0.1.2 | Mar 27, 2021 |
#2207 in Rust patterns
43KB
1.5K
SLoC
Collected
Collection types that takes the maximum, the summation and more from iterators in Rust.
Usage
Every collection type in the crate implements FromIterator
, Extend
and Default
traits.
They can be built from collect()
, and can be updated by extend()
.
For example, it makes it easy to compute maximum and minimum value from an iterator
using unzip()
in single step.
use collected::{MaxVal, MinVal};
let (min, max): (MinVal<_>, MaxVal<_>) = vec![3, 1, 5, 2, 4, 3, 6]
.into_iter()
.map(|val| (val, val))
.unzip();
assert_eq!(min.unwrap(), 1);
assert_eq!(max.unwrap(), 6);
License
MIT License. See license file.
lib.rs
:
Collection types that takes the maximum, the summation and more from iterators.
Every collection type in the crate implements FromIterator
,
Extend
and Default
traits. They can be built from
collect()
, and can be updated by extend()
.
For example, it makes it easy to compute maximum and minimum value from an iterator
using unzip()
in single step.
use collected::{MaxVal, MinVal};
let (min, max): (MinVal<_>, MaxVal<_>) = vec![3, 1, 5, 2, 4, 3, 6]
.into_iter()
.map(|val| (val, val))
.unzip();
assert_eq!(min.unwrap(), 1);
assert_eq!(max.unwrap(), 6);
Dependencies
~1.5MB
~25K SLoC