This crate provides a type CollectOnceHashMap
(and the same for BTreeMap
that can be collected from an iterator just like a normal
std::collections::HashMap
, but it makes sure that a duplicated key results in
an error.
Example:
```rust
let hm = vec![(1, 1), (1, 2)]
.intoiter()
.collect::
assert!(hm.is_err()); assert!(std::matches!(hm, Err(Error::DuplicatedKey(1))));
let bm = vec![(1, 1), (1, 2)]
.intoiter()
.collect::
assert!(bm.is_err()); assert!(std::matches!(bm, Err(Error::DuplicatedKey(1)))); ```
MPL-2.0 (c) Matthias Beyer