Fix Equivalent traits for keys on Sets by removing default reflexive Equivalent impl.
This commit is contained in:
parent
6b521cb59f
commit
500ec63051
1 changed files with 6 additions and 9 deletions
15
src/map.rs
15
src/map.rs
|
|
@ -33,15 +33,6 @@ pub trait Equivalent<T>: Sized {
|
||||||
fn matches(&self, other: &T) -> bool;
|
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 {
|
pub trait Hashes {
|
||||||
fn hashed(&self) -> Hashed;
|
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> {
|
impl<E: Hashes + PartialEq> Set<E> {
|
||||||
pub fn resize(&mut self, len: usize) {
|
pub fn resize(&mut self, len: usize) {
|
||||||
self.0.resize(len)
|
self.0.resize(len)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue