Fix Equivalent traits for keys on Sets by removing default reflexive Equivalent impl.

This commit is contained in:
paladin 2026-09-29 11:03:56 +01:00
parent 6b521cb59f
commit 500ec63051

View file

@ -33,15 +33,6 @@ pub trait Equivalent<T>: Sized {
fn matches(&self, other: &T) -> bool;
}
impl<T> Equivalent<T> for T
where
T: PartialEq,
{
fn matches(&self, other: &T) -> bool {
self == other
}
}
pub trait Hashes {
fn hashed(&self) -> Hashed;
}
@ -376,6 +367,12 @@ impl<E: Hashes + PartialEq> Equivalent<E> for SetEntry<E> {
}
}
impl<K, E: PartialEq + Hashes> Equivalent<K> for SetEntry<E> where K: Equivalent<E> {
fn matches(&self, other: &K) -> bool {
other.matches(&self.0.as_ref().unwrap())
}
}
impl<E: Hashes + PartialEq> Set<E> {
pub fn resize(&mut self, len: usize) {
self.0.resize(len)