Implement `Equivalent` and `Comparable` for tuples
One of the reasons people reach out to hashbrown instead of HashMap from std is to be able to lookup in maps like `HashMap<(String, String), Thing>` using `(&str, &str)`. However, in it's current form it requires some newtype boilerplate. This PR aims to fix it by providing impls which make tuples `Equivalent` and `Comparable` to other tuples if they are `Equivalent`/`Comparable` element-wise.
This will probably also need a corresponding PR to hashbrown repo as well for their fallback `Equivalent` definition.
Impls are included for tuples with arity up to 12 inclusive. The justification for this exact limit is prior art from std, which has the same limits.
I deliberately avoided defining recursive macro to lower the impact on compile times, but it can be changed (this crate is rarely compiled from scratch).
合并状态:未合并 关闭于 2026-02-25 2 条评论