#hash-map #no-std

no-std equivalent

Traits for key comparison in maps

4 releases (stable)

Uses old Rust 2015

1.0.2 Feb 14, 2025
1.0.1 Jul 10, 2023
1.0.0 Jun 6, 2023
0.1.0 Feb 5, 2023

#83 in Data structures

Download history 2711693/week @ 2024-12-05 2664705/week @ 2024-12-12 1799532/week @ 2024-12-19 1415825/week @ 2024-12-26 2269884/week @ 2025-01-02 2829715/week @ 2025-01-09 2690336/week @ 2025-01-16 2787877/week @ 2025-01-23 2901029/week @ 2025-01-30 3117253/week @ 2025-02-06 3286608/week @ 2025-02-13 3905456/week @ 2025-02-20 3873539/week @ 2025-02-27 4217712/week @ 2025-03-06 4242201/week @ 2025-03-13 4166717/week @ 2025-03-20

17,178,759 downloads per month
Used in 35,812 crates (24 directly)

Apache-2.0 OR MIT

8KB

Equivalent

crates.io docs

Equivalent and Comparable are Rust traits for key comparison in maps.

These may be used in the implementation of maps where the lookup type Q may be different than the stored key type K.

  • Q: Equivalent<K> checks for equality, similar to the HashMap<K, V> constraint K: Borrow<Q>, Q: Eq.
  • Q: Comparable<K> checks the ordering, similar to the BTreeMap<K, V> constraint K: Borrow<Q>, Q: Ord.

These traits are not used by the maps in the standard library, but they may add more flexibility in third-party map implementations, especially in situations where a strict K: Borrow<Q> relationship is not available.

License

Equivalent is distributed under the terms of both the MIT license and the Apache License (Version 2.0). See LICENSE-APACHE and LICENSE-MIT for details. Opening a pull request is assumed to signal agreement with these licensing terms.

No runtime deps