#hash-set #hash-map #hash #map #set #replace

hashable

HashMap and HashSet replacements that implement the Hash trait -- HashableHashMap and HashableHashSet

1 unstable release

0.0.0 Feb 13, 2021

#56 in #hash-set

Download history 2/week @ 2024-07-20 4/week @ 2024-07-27 9/week @ 2024-09-21 50/week @ 2024-10-12 27/week @ 2024-10-19 39/week @ 2024-10-26 16/week @ 2024-11-02

132 downloads per month

MIT license

13KB
272 lines

crates.io docs.rs LICENSE

This Rust library provides HashMap and HashSet replacements that implement the Hash trait -- HashableHashMap and HashableHashSet.

Contribution

Contributions are welcome! Please fork the library, push changes to your fork, and send a pull request. All contributions are shared under an MIT license unless explicitly stated otherwise in the pull request.

License

Hashable is copyright 2021 Jonathan Nadal. It is made available under the MIT License.


lib.rs:

This library provides HashMap and HashSet replacements that implement the Hash trait -- HashableHashMap and HashableHashSet.

Example

The following is rejected by the compiler:

let mut inner_set = std::collections::HashSet::new();
inner_set.insert("inner value");

let mut outer_set = std::collections::HashSet::new();
outer_set.insert(inner_set);
error[E0277]: the trait bound `HashSet<&str>: Hash` is not satisfied

The error can be resolved by swapping the inner HashSet with HashableHashSet:

let mut inner_set = hashable::HashableHashSet::new();
inner_set.insert("inner value");

let mut outer_set = std::collections::HashSet::new();
outer_set.insert(inner_set);

Dependencies

~255–640KB
~13K SLoC