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

hashable

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

1 unstable release

0.0.0 Feb 13, 2021

#49 in #hash-set

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

~260–640KB
~13K SLoC