| 1 | # Equivalent |
| 2 | |
| 3 | [](https://crates.io/crates/equivalent) |
| 4 | [](https://docs.rs/equivalent) |
| 5 | |
| 6 | `Equivalent` and `Comparable` are Rust traits for key comparison in maps. |
| 7 | |
| 8 | These may be used in the implementation of maps where the lookup type `Q` |
| 9 | may be different than the stored key type `K`. |
| 10 | |
| 11 | * `Q: Equivalent<K>` checks for equality, similar to the `HashMap<K, V>` |
| 12 | constraint `K: Borrow<Q>, Q: Eq`. |
| 13 | * `Q: Comparable<K>` checks the ordering, similar to the `BTreeMap<K, V>` |
| 14 | constraint `K: Borrow<Q>, Q: Ord`. |
| 15 | |
| 16 | These traits are not used by the maps in the standard library, but they may |
| 17 | add more flexibility in third-party map implementations, especially in |
| 18 | situations where a strict `K: Borrow<Q>` relationship is not available. |
| 19 | |
| 20 | ## License |
| 21 | |
| 22 | Equivalent is distributed under the terms of both the MIT license and the |
| 23 | Apache License (Version 2.0). See [LICENSE-APACHE](LICENSE-APACHE) and |
| 24 | [LICENSE-MIT](LICENSE-MIT) for details. Opening a pull request is |
| 25 | assumed to signal agreement with these licensing terms. |